CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.10 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.10
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
      • Iterator
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class TreePrinter

Iterator for flattening elements in a tree structure while adding some visual markers for their relative position in the tree

Namespace: Cake\Collection\Iterator

Property 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

  • _createMatcherFilter() protected

    Returns a callable that receives a value and will return whether or not it matches certain condition.

  • _extract() protected

    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 {*}

  • _fetchCurrent() protected

    Returns the current iteration element and caches its value

  • _propertyExtractor() protected

    Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.

  • _simpleExtract() protected

    Returns a column from $data that can be extracted by iterating over the column names contained in $path

  • _unwrap() public deprecated

    Backwards compatible wrapper for unwrap()

  • append() public

    {@inheritDoc}

  • appendItem() public

    {@inheritDoc}

  • avg() public

    {@inheritDoc}

  • buffered() public

    {@inheritDoc}

  • cartesianProduct() public
  • chunk() public

    {@inheritDoc}

  • chunkWithKeys() public

    {@inheritDoc}

  • combine() public

    {@inheritDoc}

  • compile() public

    {@inheritDoc}

  • contains() public

    {@inheritDoc}

  • count() public

    {@inheritDoc}

  • countBy() public

    {@inheritDoc}

  • countKeys() public

    {@inheritDoc}

  • current() public

    Returns the current iteration value

  • each() public

    {@inheritDoc}

  • every() public

    {@inheritDoc}

  • extract() public

    {@inheritDoc}

  • filter() public

    {@inheritDoc}

  • first() public

    {@inheritDoc}

  • firstMatch() public

    {@inheritDoc}

  • groupBy() public

    {@inheritDoc}

  • indexBy() public

    {@inheritDoc}

  • insert() public

    {@inheritDoc}

  • isEmpty() public

    {@inheritDoc}

  • jsonSerialize() public

    {@inheritDoc}

  • key() public

    Returns the current iteration key

  • last() public

    {@inheritDoc}

  • lazy() public

    {@inheritDoc}

  • listNested() public

    {@inheritDoc}

  • map() public

    {@inheritDoc}

  • match() public

    {@inheritDoc}

  • max() public

    {@inheritDoc}

  • median() public

    {@inheritDoc}

  • min() public

    {@inheritDoc}

  • nest() public

    {@inheritDoc}

  • newCollection() protected

    Returns a new collection.

  • next() public

    Advances the cursor one position

  • optimizeUnwrap() protected

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

  • prepend() public

    {@inheritDoc}

  • prependItem() public

    {@inheritDoc}

  • reduce() public

    {@inheritDoc}

  • reject() public

    {@inheritDoc}

  • sample() public

    {@inheritDoc}

  • shuffle() public

    {@inheritDoc}

  • skip() public

    {@inheritDoc}

  • some() public

    {@inheritDoc}

  • sortBy() public

    {@inheritDoc}

  • stopWhen() public

    {@inheritDoc}

  • sumOf() public

    {@inheritDoc}

  • take() public

    {@inheritDoc}

  • takeLast() public

    {@inheritDoc}

  • through() public

    {@inheritDoc}

  • toArray() public

    {@inheritDoc}

  • toList() public

    {@inheritDoc}

  • transpose() public

    {@inheritDoc}

  • unfold() public

    {@inheritDoc}

  • unwrap() public

    {@inheritDoc}

  • zip() public

    {@inheritDoc}

  • zipWith() public

    {@inheritDoc}

Method Detail

__construct() ¶ public

__construct(RecursiveIterator $items, string|callable $valuePath, string|callable $keyPath, string $spacer, int $mode = 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.

int $mode optional

Iterator mode.

_createMatcherFilter() ¶ protected

_createMatcherFilter(array $conditions): Closure

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
Closure

_extract() ¶ protected

_extract(array|ArrayAccess $data, string[] $path): mixed

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.

string[] $path

Path to extract from.

Returns
mixed

_fetchCurrent() ¶ protected

_fetchCurrent(): mixed

Returns the current iteration element and caches its value

Returns
mixed

_propertyExtractor() ¶ protected

_propertyExtractor(string|callable $callback): callable

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

_simpleExtract() ¶ protected

_simpleExtract(array|ArrayAccess $data, string[] $path): mixed

Returns a column from $data that can be extracted by iterating over the column names contained in $path

Parameters
array|ArrayAccess $data

Data.

string[] $path

Path to extract from.

Returns
mixed

_unwrap() ¶ public

_unwrap(): Traversable

Backwards compatible wrapper for unwrap()

Returns
Traversable

append() ¶ public

append(mixed $items)

{@inheritDoc}

Parameters
$items

appendItem() ¶ public

appendItem(mixed $item, mixed $key = null)

{@inheritDoc}

Parameters
$item
$key optional

avg() ¶ public

avg(mixed $matcher = null)

{@inheritDoc}

Parameters
$matcher optional

buffered() ¶ public

buffered(): Cake\Collection\Iterator\BufferedIterator

{@inheritDoc}

Returns
Cake\Collection\Iterator\BufferedIterator

cartesianProduct() ¶ public

cartesianProduct(callable|null $operation = null, callable|null $filter = null): Cake\Collection\CollectionInterface
Parameters
callable|null $operation optional

Operation

callable|null $filter optional

Filter

Returns
Cake\Collection\CollectionInterface
Throws
LogicException

chunk() ¶ public

chunk(mixed $chunkSize)

{@inheritDoc}

Parameters
$chunkSize

chunkWithKeys() ¶ public

chunkWithKeys(mixed $chunkSize, mixed $preserveKeys = true)

{@inheritDoc}

Parameters
$chunkSize
$preserveKeys optional

combine() ¶ public

combine(mixed $keyPath, mixed $valuePath, mixed $groupPath = null)

{@inheritDoc}

Parameters
$keyPath
$valuePath
$groupPath optional

compile() ¶ public

compile(mixed $preserveKeys = true)

{@inheritDoc}

Parameters
$preserveKeys optional

contains() ¶ public

contains(mixed $value)

{@inheritDoc}

Parameters
$value

count() ¶ public

count(): int

{@inheritDoc}

Returns
int

countBy() ¶ public

countBy(mixed $callback)

{@inheritDoc}

Parameters
$callback

countKeys() ¶ public

countKeys(): int

{@inheritDoc}

Returns
int

current() ¶ public

current(): string

Returns the current iteration value

Returns
string

each() ¶ public

each(callable $c)

{@inheritDoc}

Parameters
callable $c

every() ¶ public

every(callable $c)

{@inheritDoc}

Parameters
callable $c

extract() ¶ public

extract(mixed $matcher)

{@inheritDoc}

Parameters
$matcher

filter() ¶ public

filter(callable $c = null): Cake\Collection\Iterator\FilterIterator

{@inheritDoc}

Parameters
callable $c optional
Returns
Cake\Collection\Iterator\FilterIterator

first() ¶ public

first()

{@inheritDoc}

firstMatch() ¶ public

firstMatch(array $conditions)

{@inheritDoc}

Parameters
array $conditions

groupBy() ¶ public

groupBy(mixed $callback)

{@inheritDoc}

Parameters
$callback

indexBy() ¶ public

indexBy(mixed $callback)

{@inheritDoc}

Parameters
$callback

insert() ¶ public

insert(mixed $path, mixed $values): Cake\Collection\Iterator\InsertIterator

{@inheritDoc}

Parameters
$path
$values
Returns
Cake\Collection\Iterator\InsertIterator

isEmpty() ¶ public

isEmpty()

{@inheritDoc}

jsonSerialize() ¶ public

jsonSerialize()

{@inheritDoc}

key() ¶ public

key(): mixed

Returns the current iteration key

Returns
mixed

last() ¶ public

last()

{@inheritDoc}

lazy() ¶ public

lazy()

{@inheritDoc}

listNested() ¶ public

listNested(mixed $dir = 'desc', mixed $nestingKey = 'children'): Cake\Collection\Iterator\TreeIterator

{@inheritDoc}

Parameters
$dir optional
$nestingKey optional
Returns
Cake\Collection\Iterator\TreeIterator

map() ¶ public

map(callable $c): Cake\Collection\Iterator\ReplaceIterator

{@inheritDoc}

Parameters
callable $c
Returns
Cake\Collection\Iterator\ReplaceIterator

match() ¶ public

match(array $conditions)

{@inheritDoc}

Parameters
array $conditions

max() ¶ public

max(mixed $callback, mixed $type = \SORT_NUMERIC)

{@inheritDoc}

Parameters
$callback
$type optional

median() ¶ public

median(mixed $matcher = null)

{@inheritDoc}

Parameters
$matcher optional

min() ¶ public

min(mixed $callback, mixed $type = \SORT_NUMERIC)

{@inheritDoc}

Parameters
$callback
$type optional

nest() ¶ public

nest(mixed $idPath, mixed $parentPath, mixed $nestingKey = 'children')

{@inheritDoc}

Parameters
$idPath
$parentPath
$nestingKey optional

newCollection() ¶ protected

newCollection(mixed ...$args): Cake\Collection\CollectionInterface

Returns a new collection.

Allows classes which use this trait to determine their own type of returned collection interface

Parameters
mixed ...$args

Constructor arguments.

Returns
Cake\Collection\CollectionInterface

next() ¶ public

next(): void

Advances the cursor one position

Returns
void

optimizeUnwrap() ¶ protected

optimizeUnwrap(): Traversable|array

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

Returns
Traversable|array

prepend() ¶ public

prepend(mixed $items)

{@inheritDoc}

Parameters
$items

prependItem() ¶ public

prependItem(mixed $item, mixed $key = null)

{@inheritDoc}

Parameters
$item
$key optional

reduce() ¶ public

reduce(callable $c, mixed $zero = null)

{@inheritDoc}

Parameters
callable $c
$zero optional

reject() ¶ public

reject(callable $c): Cake\Collection\Iterator\FilterIterator

{@inheritDoc}

Parameters
callable $c
Returns
Cake\Collection\Iterator\FilterIterator

sample() ¶ public

sample(mixed $size = 10)

{@inheritDoc}

Parameters
$size optional

shuffle() ¶ public

shuffle()

{@inheritDoc}

skip() ¶ public

skip(mixed $howMany)

{@inheritDoc}

Parameters
$howMany

some() ¶ public

some(callable $c)

{@inheritDoc}

Parameters
callable $c

sortBy() ¶ public

sortBy(mixed $callback, mixed $dir = \SORT_DESC, mixed $type = \SORT_NUMERIC)

{@inheritDoc}

Parameters
$callback
$dir optional
$type optional

stopWhen() ¶ public

stopWhen(mixed $condition): Cake\Collection\Iterator\StoppableIterator

{@inheritDoc}

Parameters
$condition
Returns
Cake\Collection\Iterator\StoppableIterator

sumOf() ¶ public

sumOf(mixed $matcher = null)

{@inheritDoc}

Parameters
$matcher optional

take() ¶ public

take(mixed $size = 1, mixed $from = 0)

{@inheritDoc}

Parameters
$size optional
$from optional

takeLast() ¶ public

takeLast(mixed $howMany)

{@inheritDoc}

Parameters
$howMany

through() ¶ public

through(callable $handler)

{@inheritDoc}

Parameters
callable $handler

toArray() ¶ public

toArray(mixed $preserveKeys = true)

{@inheritDoc}

Parameters
$preserveKeys optional

toList() ¶ public

toList()

{@inheritDoc}

transpose() ¶ public

transpose(): Cake\Collection\CollectionInterface

{@inheritDoc}

Returns
Cake\Collection\CollectionInterface
Throws
LogicException

unfold() ¶ public

unfold(callable $transformer = null)

{@inheritDoc}

Parameters
callable $transformer optional

unwrap() ¶ public

unwrap()

{@inheritDoc}

zip() ¶ public

zip(mixed $items)

{@inheritDoc}

Parameters
$items

zipWith() ¶ public

zipWith(mixed $items, mixed $callable)

{@inheritDoc}

Parameters
$items
$callable

Property Detail

$_current ¶ protected

Cached value for the current iteration element

Type
mixed

$_key ¶ protected

A callable to generate the iteration key

Type
callable

$_spacer ¶ protected

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

Type
string

$_value ¶ protected

A callable to extract the display value

Type
callable
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs