$_mode
$_mode : integer
The iteration mode
A Recursive iterator used to flatten nested structures and also exposes all Collection methods
filter(callable $c = null) : \Cake\Collection\Iterator\FilterIterator
{@inheritDoc}
callable | $c |
reject(callable $c) : \Cake\Collection\Iterator\FilterIterator
{@inheritDoc}
callable | $c |
map(callable $c) : \Cake\Collection\Iterator\ReplaceIterator
{@inheritDoc}
callable | $c |
insert( $path, $values) : \Cake\Collection\Iterator\InsertIterator
{@inheritDoc}
$path | ||
$values |
buffered() : \Cake\Collection\Iterator\BufferedIterator
{@inheritDoc}
listNested( $dir = 'desc', $nestingKey = 'children') : \Cake\Collection\Iterator\TreeIterator
{@inheritDoc}
$dir | ||
$nestingKey |
stopWhen( $condition) : \Cake\Collection\Iterator\StoppableIterator
{@inheritDoc}
$condition |
cartesianProduct(callable|null $operation = null, callable|null $filter = null) : \Cake\Collection\CollectionInterface
callable|null | $operation | Operation |
callable|null | $filter | Filter |
transpose() : \Cake\Collection\CollectionInterface
{@inheritDoc}
printer(string|callable $valuePath, string|callable|null $keyPath = null, string $spacer = '__') : \Cake\Collection\Iterator\TreePrinter
Returns another iterator which will return the values ready to be displayed to a user. It does so by extracting one property from each of the elements and prefixing it with a spacer so that the relative position in the tree can be visualized.
Both $valuePath and $keyPath can be a string with a property name to extract or a dot separated path of properties that should be followed to get the last one in the path.
Alternatively, $valuePath and $keyPath can be callable functions. They will get the current element as first parameter, the current iteration key as second parameter, and the iterator instance as third argument.
$printer = (new Collection($treeStructure))->listNested()->printer('name');
Using a closure:
$printer = (new Collection($treeStructure))
->listNested()
->printer(function ($item, $key, $iterator) {
return $item->name;
});
string|callable | $valuePath | The property to extract or a callable to return the display value |
string|callable|null | $keyPath | The property to use as iteration key or a callable returning the key value. |
string | $spacer | The string to use for prefixing the values according to their depth in the tree |