Class NestIterator
A type of collection that is aware of nested items and exposes methods to check or retrieve them
- IteratorIterator implements Iterator, Traversable, OuterIterator
- Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
- Cake\Collection\Iterator\NestIterator implements RecursiveIterator
Properties summary
-
$_nestKey
protectedstring|callable
The name of the property that contains the nested items for each element
Method Summary
-
__construct() public
Constructor -
getChildren() public
Returns a traversable containing the children for the current item -
hasChildren() public
Returns true if there is an array or a traversable object stored under the configured nestKey for the current item
Method Detail
__construct() public ¶
__construct( array|Traversable $items , string|callable $nestKey )
Constructor
Parameters
- array|Traversable $items
- Collection items.
- string|callable $nestKey
the property that contains the nested items If a callable is passed, it should return the childrens for the passed item
Throws
If passed incorrect type for items.
Overrides
getChildren() public ¶
getChildren( )
Returns a traversable containing the children for the current item
Returns
Implementation of
RecursiveIterator::getChildren()
hasChildren() public ¶
hasChildren( )
Returns true if there is an array or a traversable object stored under the configured nestKey for the current item
Returns
Implementation of
RecursiveIterator::hasChildren()
Methods inherited from Cake\Collection\Collection
__debugInfo() public ¶
__debugInfo( )
Returns an array that can be used to describe the internal state of this object.
Returns
count() public ¶
count( )
Returns the amount of elements in the collection.
Returns
Implementation of
countKeys() public ¶
countKeys( )
Returns the number of unique keys in this iterator. This is, the number of
elements the collection will contain after calling toArray()
Returns
Implementation of
serialize() public ¶
serialize( )
Returns a string representation of this object that can be used to reconstruct it
Returns
Implementation of
Serializable::serialize()
unserialize() public ¶
unserialize( string $collection )
Unserializes the passed string and rebuilds the Collection instance
Parameters
- string $collection
- The serialized collection
Implementation of
Serializable::unserialize()
Methods used from Cake\Collection\CollectionTrait
cartesianProduct() public ¶
cartesianProduct( callable $operation null , callable $filter null )
Parameters
- callable $operation optional null
- Operation
- callable $filter optional null
- Filter
Returns
Throws
optimizeUnwrap() protected ¶
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Magic methods inherited from Cake\Collection\CollectionInterface
cartesianProduct()
|