Class TreePrinter
Iterator for flattening elements in a tree structure while adding some visual markers for their relative position in the tree
- RecursiveIteratorIterator implements Iterator, Traversable, OuterIterator
- Cake\Collection\Iterator\TreePrinter uses Cake\Collection\CollectionTrait
Inherited Constants
-
CATCH_GET_CHILD
,CHILD_FIRST
,LEAVES_ONLY
,SELF_FIRST
Properties summary
-
$_current
protectedmixed
Cached value for the current iteration element -
$_key
protectedcallable
A callable to generate the iteration key -
$_spacer
protectedstring
The string to use for prefixing the values according to their depth in the tree. -
$_value
protectedcallable
A callable to extract the display value
Method Summary
-
__construct() public
Constructor -
_fetchCurrent() protected
Returns the current iteration element and caches its value -
current() public
Returns the current iteration value -
key() public
Returns the current iteration key -
next() public
Advances the cursor one position
Method Detail
__construct() public ¶
__construct( RecursiveIterator $items , string|callable $valuePath , string|callable $keyPath , string $spacer , integer $mode Cake\Collection\Iterator\RecursiveIteratorIterator::SELF_FIRST )
Constructor
Parameters
- RecursiveIterator $items
- The iterator to flatten.
- string|callable $valuePath
The property to extract or a callable to return the display value.
- string|callable $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.
- integer $mode optional Cake\Collection\Iterator\RecursiveIteratorIterator::SELF_FIRST
- Iterator mode.
Overrides
RecursiveIteratorIterator::__construct()
_fetchCurrent() protected ¶
_fetchCurrent( )
Returns the current iteration element and caches its value
Returns
current() public ¶
current( )
Returns the current iteration value
Returns
Overrides
RecursiveIteratorIterator::current()
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