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
protectedCached value for the current iteration elementmixed
-
$_key
protectedA callable to generate the iteration keycallable
-
$_spacer
protectedThe string to use for prefixing the values according to their depth in the tree.string
-
$_value
protectedA callable to extract the display valuecallable
Method Summary
- __construct() publicConstructor
- _fetchCurrent() protectedReturns the current iteration element and caches its value
- current() publicReturns the current iteration value
- key() publicReturns the current iteration key
- next() publicAdvances the cursor one position
Method Detail
__construct()source 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()source protected
_fetchCurrent( )
Returns the current iteration element and caches its value
Returns
mixedcurrent()source public
current( )
Returns the current iteration value
Returns
stringOverrides
RecursiveIteratorIterator::current()
key()source public
key( )
Returns the current iteration key
Returns
mixedOverrides
RecursiveIteratorIterator::key()
next()source public
next( )
Advances the cursor one position
Overrides
RecursiveIteratorIterator::next()
Methods used from Cake\Collection\CollectionTrait
_unwrap()source public
_unwrap( )
append()source public
append( $items )
avg()source public
avg( $matcher null )
cartesianProduct()source public
cartesianProduct( callable $operation null , callable $filter null )
Returns
Cake\Collection\CollectionInterface
chunk()source public
chunk( $chunkSize )
chunkWithKeys()source public
chunkWithKeys( $chunkSize , $preserveKeys true )
combine()source public
combine( $keyPath , $valuePath , $groupPath null )
compile()source public
compile( $preserveKeys true )
contains()source public
contains( $value )
countBy()source public
countBy( $callback )
each()source public
each( callable $c )
every()source public
every( callable $c )
extract()source public
extract( $matcher )
first()source public
first( )
firstMatch()source public
firstMatch( array $conditions )
groupBy()source public
groupBy( $callback )
indexBy()source public
indexBy( $callback )
isEmpty()source public
isEmpty( )
jsonSerialize()source public
jsonSerialize( )
last()source public
last( )
listNested()source public
listNested( $dir 'desc' , $nestingKey 'children' )
Returns
Cake\Collection\Iterator\TreeIterator
match()source public
match( array $conditions )
max()source public
max( $callback , $type SORT_NUMERIC )
median()source public
median( $matcher null )
min()source public
min( $callback , $type SORT_NUMERIC )
nest()source public
nest( $idPath , $parentPath , $nestingKey 'children' )
optimizeUnwrap()source protected
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Traversable|arrayreduce()source public
reduce( callable $c , $zero null )
sample()source public
sample( $size 10 )
shuffle()source public
shuffle( )
skip()source public
skip( $howMany )
some()source public
some( callable $c )
sortBy()source public
sortBy( $callback , $dir SORT_DESC , $type SORT_NUMERIC )
sumOf()source public
sumOf( $matcher null )
take()source public
take( $size 1 , $from 0 )
through()source public
through( callable $handler )
toArray()source public
toArray( $preserveKeys true )
toList()source public
toList( )
unfold()source public
unfold( callable $transformer null )
unwrap()source public
unwrap( )
zip()source public
zip( $items )
zipWith()source public
zipWith( $items , $callable )
Properties detail
$_spacersource
protected string
The string to use for prefixing the values according to their depth in the tree.
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Collection.Iterator.TreePrinter.html