Elgg
Version 4.x
|
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 ($position) | ||||
{} 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 14 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 |
Definition at line 41 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 89 of file Collection.php.
Elgg\Collections\Collection::all | ( | ) |
{Returns all collection items by reference.
Implements Elgg\Collections\CollectionInterface.
Definition at line 74 of file Collection.php.
|
protected |
Validate if item is a valid collection item.
mixed | $item | Item |
Definition at line 63 of file Collection.php.
Elgg\Collections\Collection::count | ( | ) |
{Count collection items.
Implements Elgg\Collections\CollectionInterface.
Definition at line 82 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 121 of file Collection.php.
Elgg\Collections\Collection::filter | ( | callable | $callback = null | ) |
{Filter collection items using a custom filter Returns a new collection instance.
callable | $callback | Filter |
Implements Elgg\Collections\CollectionInterface.
Definition at line 144 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 100 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 107 of file Collection.php.
Elgg\Collections\Collection::key | ( | ) |
{}
Definition at line 280 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 199 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 133 of file Collection.php.
Elgg\Collections\Collection::next | ( | ) |
{}
Definition at line 272 of file Collection.php.
Elgg\Collections\Collection::offsetExists | ( | $offset | ) |
Elgg\Collections\Collection::offsetGet | ( | $offset | ) |
{}
Definition at line 226 of file Collection.php.
Elgg\Collections\Collection::offsetSet | ( | $offset, | |
$value | |||
) |
{}
Definition at line 234 of file Collection.php.
Elgg\Collections\Collection::offsetUnset | ( | $offset | ) |
{}
Definition at line 245 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 114 of file Collection.php.
Elgg\Collections\Collection::rewind | ( | ) |
{}
Definition at line 300 of file Collection.php.
Elgg\Collections\Collection::seek | ( | $position | ) |
{}
Definition at line 308 of file Collection.php.
Elgg\Collections\Collection::sort | ( | callable | $callback = null | ) |
{Sort fields using custom callable If not provided, will sort items by priority.
callable | $callback | Sorter |
Implements Elgg\Collections\CollectionInterface.
Definition at line 157 of file Collection.php.
Elgg\Collections\Collection::valid | ( | ) |
{}
Definition at line 290 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 188 of file Collection.php.
|
protected |
Definition at line 27 of file Collection.php.
|
protected |
Definition at line 22 of file Collection.php.
|
protected |
Definition at line 32 of file Collection.php.