W3cubDocs

/CakePHP 3.8

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( )

append()source public

append( $items )

appendItem()source public

appendItem( $item , $key = null )

avg()source public

avg( $matcher = null )

buffered()source public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator

cartesianProduct()source public

cartesianProduct( callable $operation = null , callable $filter = null )

Parameters

callable $operation optional null
Operation
callable $filter optional null
Filter

Returns

Cake\Collection\CollectionInterface

Throws

LogicException

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 )

count()source public

count( )

Returns

integer

countBy()source public

countBy( $callback )

countKeys()source public

countKeys( )

Returns

integer

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( )

lazy()source public

lazy( )

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 )

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\CollectionInterface

optimizeUnwrap()source protected

optimizeUnwrap( )

Unwraps this iterator and returns the simplest traversable that can be used for getting the data out

Returns

Traversable|array

prepend()source public

prepend( $items )

prependItem()source public

prependItem( $item , $key = null )

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 )

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\CollectionInterface

Throws

LogicException

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–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