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
Extended by Cake\Collection\Iterator\TreePrinter uses Cake\Collection\CollectionTrait

Inherited Constants

  • CATCH_GET_CHILD, CHILD_FIRST, LEAVES_ONLY, SELF_FIRST

Properties summary

  • $_current protected
    mixed
    Cached value for the current iteration element
  • $_key protected
    callable
    A callable to generate the iteration key
  • $_spacer protected
    string
    The string to use for prefixing the values according to their depth in the tree.
  • $_value protected
    callable
    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()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

mixed

current()source public

current( )

Returns the current iteration value

Returns

string

Overrides

RecursiveIteratorIterator::current()

key()source public

key( )

Returns the current iteration key

Returns

mixed

Overrides

RecursiveIteratorIterator::key()

next()source public

next( )

Advances the cursor one position

Overrides

RecursiveIteratorIterator::next()

Methods used from Cake\Collection\CollectionTrait

_unwrap()source public

_unwrap( )

Backwards compatible wrapper for unwrap()

Deprecated

Returns

Iterator

append()source public

append( $items )

buffered()source public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator

chunk()source public

chunk( $chunkSize )

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 )

filter()source public

filter( callable $c null )

Returns

Cake\Collection\Iterator\FilterIterator

first()source public

first( )

firstMatch()source public

firstMatch( array $conditions )

groupBy()source public

groupBy( $callback )

indexBy()source public

indexBy( $callback )

insert()source public

insert( $path , $values )

Returns

Cake\Collection\Iterator\InsertIterator

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

map()source public

map( callable $c )

Returns

Cake\Collection\Iterator\ReplaceIterator

match()source public

match( array $conditions )

max()source public

max( $callback , $type SORT_NUMERIC )

min()source public

min( $callback , $type SORT_NUMERIC )

nest()source public

nest( $idPath , $parentPath )

reduce()source public

reduce( callable $c , $zero null )

reject()source public

reject( callable $c )

Returns

Cake\Collection\Iterator\FilterIterator

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 )

stopWhen()source public

stopWhen( $condition )

Returns

Cake\Collection\Iterator\StoppableIterator

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

$_currentsource

protected mixed

Cached value for the current iteration element

$_keysource

protected callable

A callable to generate the iteration key

$_spacersource

protected string

The string to use for prefixing the values according to their depth in the tree.

$_valuesource

protected callable

A callable to extract the display value

© 2005–2016 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.
http://api.cakephp.org/3.2/class-Cake.Collection.Iterator.TreePrinter.html