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
Method Detail
__constructsource 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()
_fetchCurrentsource protected
_fetchCurrent( )
Returns the current iteration element and caches its value
Returns
mixed
mixed
currentsource public
current( )
Returns the current iteration value
Returns
string
string
Overrides
RecursiveIteratorIterator::current()
keysource public
key( )
Returns the current iteration key
Returns
mixed
mixed
Overrides
RecursiveIteratorIterator::key()
nextsource public
next( )
Advances the cursor one position
Overrides
RecursiveIteratorIterator::next()
Methods used from Cake\Collection\CollectionTrait
_unwrapsource public
_unwrap( )
Backwards compatible wrapper for unwrap()
Deprecated
Returns
Iterator
\Iterator
appendsource public
append( mixed $items )
bufferedsource public
buffered( )
Returns
Cake\Collection\Iterator\BufferedIterator
\Cake\Collection\Iterator\BufferedIterator
chunksource public
chunk( mixed $chunkSize )
combinesource public
combine( mixed $keyPath , mixed $valuePath , mixed $groupPath null )
compilesource public
compile( mixed $preserveKeys true )
containssource public
contains( mixed $value )
countBysource public
countBy( mixed $callback )
eachsource public
each( callable $c )
everysource public
every( callable $c )
extractsource public
extract( mixed $matcher )
filtersource public
filter( callable $c null )
Returns
Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator
firstsource public
first( )
firstMatchsource public
firstMatch( array $conditions )
groupBysource public
groupBy( mixed $callback )
indexBysource public
indexBy( mixed $callback )
insertsource public
insert( mixed $path , mixed $values )
Returns
Cake\Collection\Iterator\InsertIterator
\Cake\Collection\Iterator\InsertIterator
isEmptysource public
isEmpty( )
jsonSerializesource public
jsonSerialize( )
lastsource public
last( )
listNestedsource public
listNested( mixed $dir 'desc' , mixed $nestingKey 'children' )
Returns
Cake\Collection\Iterator\TreeIterator
\Cake\Collection\Iterator\TreeIterator
mapsource public
map( callable $c )
Returns
Cake\Collection\Iterator\ReplaceIterator
\Cake\Collection\Iterator\ReplaceIterator
matchsource public
match( array $conditions )
maxsource public
max( mixed $callback , mixed $type SORT_NUMERIC )
minsource public
min( mixed $callback , mixed $type SORT_NUMERIC )
nestsource public
nest( mixed $idPath , mixed $parentPath )
reducesource public
reduce( callable $c , mixed $zero null )
rejectsource public
reject( callable $c )
Returns
Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator
samplesource public
sample( mixed $size 10 )
shufflesource public
shuffle( )
skipsource public
skip( mixed $howMany )
somesource public
some( callable $c )
sortBysource public
sortBy( mixed $callback , mixed $dir SORT_DESC , mixed $type SORT_NUMERIC )
stopWhensource public
stopWhen( mixed $condition )
Returns
Cake\Collection\Iterator\StoppableIterator
\Cake\Collection\Iterator\StoppableIterator
sumOfsource public
sumOf( mixed $matcher null )
takesource public
take( mixed $size 1 , mixed $from 0 )
throughsource public
through( callable $handler )
toArraysource public
toArray( mixed $preserveKeys true )
toListsource public
toList( )
unfoldsource public
unfold( callable $transformer null )
unwrapsource public
unwrap( )
zipsource public
zip( mixed $items )
zipWithsource public
zipWith( mixed $items , mixed $callable )
Methods used from Cake\Collection\ExtractTrait
_createMatcherFiltersource protected
_createMatcherFilter( array $conditions )
Returns a callable that receives a value and will return whether or not it matches certain condition.
Parameters
- array
$conditions
- A key-value list of conditions to match where the key is the property path to get from the current item and the value is the value to be compared the item with.
Returns
callable
callable
_extractsource protected
_extract( array|ArrayAccess $data , array $path )
Returns a column from $data that can be extracted by iterating over the column names contained in $path. It will return arrays for elements in represented with {*}
Parameters
- array|ArrayAccess
$data
- Data.
- array
$path
- Path to extract from.
Returns
mixed
mixed
_propertyExtractorsource protected
_propertyExtractor( string|callable $callback )
Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.
Parameters
- string|callable
$callback
- A dot separated path of column to follow so that the final one can be returned or a callable that will take care of doing that.
Returns
callable
callable
_simpleExtractsource protected
_simpleExtract( array|ArrayAccess $data , array $path )
Returns a column from $data that can be extracted by iterating over the column names contained in $path
Parameters
- array|ArrayAccess
$data
- Data.
- array
$path
- Path to extract from.
Returns
mixed
mixed
Constants inherited from RecursiveIteratorIterator
CATCH_GET_CHILD, CHILD_FIRST, LEAVES_ONLY, SELF_FIRST |
Properties summary
© 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.1/class-Cake.Collection.Iterator.TreePrinter.html