On this page
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
- 
    $_currentprotectedCached value for the current iteration elementmixed
- 
    $_keyprotectedA callable to generate the iteration keycallable
- 
    $_spacerprotectedThe string to use for prefixing the values according to their depth in the tree.string
- 
    $_valueprotectedA 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 $modeoptional 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 )appendItem()source public
appendItem( $item , $key = null )avg()source public
avg( $matcher = null )cartesianProduct()source public
cartesianProduct( callable $operation = null , callable $filter = null )Parameters
- 
     callable $operationoptional null
- Operation
- 
     callable $filteroptional null
- Filter
Returns
Cake\Collection\CollectionInterfaceThrows
LogicExceptionchunk()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( )lazy()source public
lazy( )listNested()source public
listNested( $dir = 'desc' , $nestingKey = 'children' )Returns
Cake\Collection\Iterator\TreeIteratormatch()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' )newCollection()source protected
newCollection( ... $args )Returns a new collection.
Allows classes which use this trait to determine their own type of returned collection interface
Parameters
- 
     ... $args
- $args Constructor arguments.
Returns
Cake\Collection\CollectionInterfaceoptimizeUnwrap()source protected
optimizeUnwrap( )Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Traversable|arrayprepend()source public
prepend( $items )prependItem()source public
prependItem( $item , $key = null )reduce()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 )takeLast()source public
takeLast( $howMany )through()source public
through( callable $handler )toArray()source public
toArray( $preserveKeys = true )toList()source public
toList( )transpose()source public
transpose( )Returns
Cake\Collection\CollectionInterfaceThrows
LogicExceptionunfold()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–present 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.8/class-Cake.Collection.Iterator.TreePrinter.html