class CachedCollection extends ArrayCollection

Cached collection so that one-time iterators can be rewind

Iteration can be done by iterating directly on the object foreach ( $coll as $item ) or through it's iterator accessor : foreach ( $coll->getIterator() as $item ).

Properties

protected Iterator $_selfIterator Iterator created to walk through the collection directly by iterating through object from AbstractCollection
protected mixed[] $_array Underlying array from ArrayCollection

Methods

getSelfIterator()

Create or get the self iterator

getIterator()

Get the iterator of collection

mixed
current()

Get current item of collection iterator

mixed
key()

Get current key of collection iterator

next()

Move to next item of collection iterator

rewind()

Reset collection iterator

bool
valid()

Check if iterator is valid

__construct(Collection $col)

Constructor of cached collection

Details

in AbstractCollection at line 36
protected Iterator getSelfIterator()

Create or get the self iterator

Return Value

Iterator

in ArrayCollection at line 47
Iterator getIterator()

Get the iterator of collection

Return Value

Iterator

in AbstractCollection at line 58
mixed current()

Get current item of collection iterator

Return Value

mixed

in AbstractCollection at line 69
mixed key()

Get current key of collection iterator

Return Value

mixed

in AbstractCollection at line 78
next()

Move to next item of collection iterator

in AbstractCollection at line 87
rewind()

Reset collection iterator

in AbstractCollection at line 98
bool valid()

Check if iterator is valid

Return Value

bool True if iterator is valid or false (no more items to iterate)

at line 28
__construct(Collection $col)

Constructor of cached collection

Parameters

Collection $col