Elgg
Version 6.0
|
An interface for organizing items into collections. More...
Public Member Functions | |
all () | |
Returns all collection items by reference. More... | |
count () | |
Count collection items. More... | |
add ($item) | |
Add a new item to collection. More... | |
get ($id) | |
Get an item by its ID. More... | |
has ($id) | |
Check if collection has an item with a given ID. More... | |
remove ($id) | |
Remove item from collection by its ID. More... | |
fill ($items) | |
Replace collection items. More... | |
merge ($items) | |
Add new items to collection, replacing items with matching IDs. More... | |
filter (callable $callback=null) | |
Filter collection items using a custom filter Returns a new collection instance. More... | |
sort (callable $callback=null) | |
Sort fields using custom callable If not provided, will sort items by priority. More... | |
walk (callable $callback) | |
Walk through members of the collection and apply a callback. More... | |
map (callable $callback) | |
Walk through all items in the collection and apply a callback. More... | |
An interface for organizing items into collections.
Definition at line 8 of file CollectionInterface.php.
Elgg\Collections\CollectionInterface::add | ( | $item | ) |
Add a new item to collection.
CollectionItemInterface | $item | Item |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::all | ( | ) |
Returns all collection items by reference.
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::count | ( | ) |
Elgg\Collections\CollectionInterface::fill | ( | $items | ) |
Replace collection items.
CollectionItemInterface[]|Collection | $items Items |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::filter | ( | callable | $callback = null | ) |
Filter collection items using a custom filter Returns a new collection instance.
callable | $callback | Filter |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::get | ( | $id | ) |
Get an item by its ID.
string | int | $id | ID |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::has | ( | $id | ) |
Check if collection has an item with a given ID.
string | int | $id | ID |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::map | ( | callable | $callback | ) |
Walk through all items in the collection and apply a callback.
callable | $callback | Mapper |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::merge | ( | $items | ) |
Add new items to collection, replacing items with matching IDs.
CollectionItemInterface[]|Collection | $items Items |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::remove | ( | $id | ) |
Remove item from collection by its ID.
string | int | $id | ID |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::sort | ( | callable | $callback = null | ) |
Sort fields using custom callable If not provided, will sort items by priority.
callable | $callback | Sorter |
Implemented in Elgg\Collections\Collection.
Elgg\Collections\CollectionInterface::walk | ( | callable | $callback | ) |
Walk through members of the collection and apply a callback.
Unlike CollectionInterface::map(), this method does not return the result of mapping, rather returns the exact same instance of the collection after walking through its members by reference
callable | $callback | Callback function |
Implemented in Elgg\Collections\Collection.