|
Elgg
Version master
|
A collection of unique items. More...
Public Member Functions | ||||
| __construct ($items=[], $item_class=null) | ||||
| Constructor. More... | ||||
| all () | ||||
{Returns all collection items by reference.
| ||||
| count () | ||||
{Count collection items.
| ||||
| add ($item) | ||||
{Add a new item to collection.
| ||||
| get ($id) | ||||
{Get an item by its ID.
| ||||
| has ($id) | ||||
{Check if collection has an item with a given ID.
| ||||
| remove ($id) | ||||
{Remove item from collection by its ID.
| ||||
| fill ($items) | ||||
{Replace collection items.
| ||||
| merge ($items) | ||||
{Add new items to collection, replacing items with matching IDs.
| ||||
| filter (?callable $callback=null) | ||||
{Filter collection items using a custom filter Returns a new collection instance.
| ||||
| sort (?callable $callback=null) | ||||
{Sort fields using custom callable If not provided, will sort items by priority.
| ||||
| 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.
| ||||
| offsetExists ($offset) | ||||
| ArrayAccess interface functions. More... | ||||
| offsetGet ($offset) | ||||
| {} More... | ||||
| offsetSet ($offset, $value) | ||||
| {} More... | ||||
| offsetUnset ($offset) | ||||
| {} More... | ||||
| current () | ||||
| SeekableIterator interface functions. More... | ||||
| next () | ||||
| {} More... | ||||
| key () | ||||
| {} More... | ||||
| valid () | ||||
| {} More... | ||||
| rewind () | ||||
| {} More... | ||||
| seek ($offset) | ||||
| {} More... | ||||
Protected Member Functions | |
| assertValidItem ($item) | |
| Validate if item is a valid collection item. More... | |
Protected Attributes | |
| $items = [] | |
| $item_class | |
| $position | |
A collection of unique items.
Definition at line 11 of file Collection.php.
| Elgg\Collections\Collection::__construct | ( | $items = [], |
|
$item_class = null |
|||
| ) |
Constructor.
| CollectionItemInterface[] | $items | Items |
| string | $item_class | Member class Restrict members of the collection to instances of this class |
Reimplemented in Elgg\Menu\MenuItems.
Definition at line 38 of file Collection.php.
| Elgg\Collections\Collection::add | ( | $item | ) |
{Add a new item to collection.
| CollectionItemInterface | $item | Item |
Implements Elgg\Collections\CollectionInterface.
Definition at line 86 of file Collection.php.
| Elgg\Collections\Collection::all | ( | ) |
{Returns all collection items by reference.
Implements Elgg\Collections\CollectionInterface.
Definition at line 71 of file Collection.php.
|
protected |
Validate if item is a valid collection item.
| mixed | $item | Item |
Definition at line 60 of file Collection.php.
| Elgg\Collections\Collection::count | ( | ) |
{Count collection items.
Implements Elgg\Collections\CollectionInterface.
Definition at line 79 of file Collection.php.
| Elgg\Collections\Collection::current | ( | ) |
| Elgg\Collections\Collection::fill | ( | $items | ) |
{Replace collection items.
| CollectionItemInterface[] | Collection | $items | Items |
Implements Elgg\Collections\CollectionInterface.
Definition at line 118 of file Collection.php.
| Elgg\Collections\Collection::filter | ( | ?callable | $callback = null | ) |
{Filter collection items using a custom filter Returns a new collection instance.
| null | callable | $callback | Filter |
Implements Elgg\Collections\CollectionInterface.
Definition at line 141 of file Collection.php.
| Elgg\Collections\Collection::get | ( | $id | ) |
{Get an item by its ID.
| string | int | $id | ID |
Implements Elgg\Collections\CollectionInterface.
Definition at line 97 of file Collection.php.
| Elgg\Collections\Collection::has | ( | $id | ) |
{Check if collection has an item with a given ID.
| string | int | $id | ID |
Implements Elgg\Collections\CollectionInterface.
Definition at line 104 of file Collection.php.
| Elgg\Collections\Collection::key | ( | ) |
{}
Definition at line 277 of file Collection.php.
| Elgg\Collections\Collection::map | ( | callable | $callback | ) |
{Walk through all items in the collection and apply a callback.
| callable | $callback | Mapper |
Implements Elgg\Collections\CollectionInterface.
Definition at line 196 of file Collection.php.
| Elgg\Collections\Collection::merge | ( | $items | ) |
{Add new items to collection, replacing items with matching IDs.
| CollectionItemInterface[] | Collection | $items | Items |
Implements Elgg\Collections\CollectionInterface.
Definition at line 130 of file Collection.php.
| Elgg\Collections\Collection::next | ( | ) |
{}
Definition at line 269 of file Collection.php.
| Elgg\Collections\Collection::offsetExists | ( | $offset | ) |
| Elgg\Collections\Collection::offsetGet | ( | $offset | ) |
{}
Definition at line 223 of file Collection.php.
| Elgg\Collections\Collection::offsetSet | ( | $offset, | |
| $value | |||
| ) |
{}
Definition at line 231 of file Collection.php.
| Elgg\Collections\Collection::offsetUnset | ( | $offset | ) |
{}
Definition at line 242 of file Collection.php.
| Elgg\Collections\Collection::remove | ( | $id | ) |
{Remove item from collection by its ID.
| string | int | $id | ID |
Implements Elgg\Collections\CollectionInterface.
Definition at line 111 of file Collection.php.
| Elgg\Collections\Collection::rewind | ( | ) |
{}
Definition at line 297 of file Collection.php.
| Elgg\Collections\Collection::seek | ( | $offset | ) |
{}
Definition at line 305 of file Collection.php.
| Elgg\Collections\Collection::sort | ( | ?callable | $callback = null | ) |
{Sort fields using custom callable If not provided, will sort items by priority.
| null | callable | $callback | Sorter |
Implements Elgg\Collections\CollectionInterface.
Definition at line 154 of file Collection.php.
| Elgg\Collections\Collection::valid | ( | ) |
{}
Definition at line 287 of file Collection.php.
| Elgg\Collections\Collection::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 |
Implements Elgg\Collections\CollectionInterface.
Definition at line 185 of file Collection.php.
|
protected |
Definition at line 24 of file Collection.php.
|
protected |
Definition at line 19 of file Collection.php.
|
protected |
Definition at line 29 of file Collection.php.