Creates an iterator from another iterator that extract the requested column or property based on a path
$_extractor
protected callable
A callable responsible for extracting a single value for each item in the collection.
Creates the iterator that will return the requested property for each value in the collection expressed in $path
Returns the column value defined in $path or null if the path could not be followed
__construct( array|Traversable $items , string $path )
Creates the iterator that will return the requested property for each value in the collection expressed in $path
Extract the user name for all comments in the array:
$items = [ ['comment' => ['body' => 'cool', 'user' => ['name' => 'Mark']], ['comment' => ['body' => 'very cool', 'user' => ['name' => 'Renan']] ]; $extractor = new ExtractIterator($items, 'comment.user.name'');
$items
$path
a dot separated string symbolizing the path to follow inside the hierarchy of each value so that the column can be extracted.
Cake\Collection\Collection::__construct()
current( )
Returns the column value defined in $path or null if the path could not be followed
IteratorIterator::current()
unwrap( )
We perform here some strictness analysis so that the iterator logic is bypassed entirely.
Cake\Collection\CollectionTrait::unwrap()
__debugInfo( )
Returns an array that can be used to describe the internal state of this object.
count( )
Returns the amount of elements in the collection.
Cake\Collection\CollectionInterface::count()
countKeys( )
Returns the number of unique keys in this iterator. This is, the number of elements the collection will contain after calling toArray()
Cake\Collection\CollectionInterface::countKeys()
serialize( )
Returns a string representation of this object that can be used to reconstruct it
Serializable::serialize()
unserialize( string $collection )
Unserializes the passed string and rebuilds the Collection instance
$collection
Serializable::unserialize()
_unwrap( )
append( $items )
appendItem( $item , $key = null )
avg( $matcher = null )
cartesianProduct( callable $operation = null , callable $filter = null )
$operation
optional null $filter
optional null Cake\Collection\CollectionInterface
chunk( $chunkSize )
chunkWithKeys( $chunkSize , $preserveKeys = true )
combine( $keyPath , $valuePath , $groupPath = null )
compile( $preserveKeys = true )
contains( $value )
countBy( $callback )
each( callable $c )
every( callable $c )
extract( $matcher )
first( )
firstMatch( array $conditions )
groupBy( $callback )
indexBy( $callback )
isEmpty( )
jsonSerialize( )
last( )
lazy( )
listNested( $dir = 'desc' , $nestingKey = 'children' )
Cake\Collection\Iterator\TreeIterator
match( array $conditions )
max( $callback , $type = \SORT_NUMERIC )
median( $matcher = null )
min( $callback , $type = \SORT_NUMERIC )
nest( $idPath , $parentPath , $nestingKey = 'children' )
newCollection( ... $args )
Returns a new collection.
Allows classes which use this trait to determine their own type of returned collection interface
$args
Cake\Collection\CollectionInterface
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
prepend( $items )
prependItem( $item , $key = null )
reduce( callable $c , $zero = null )
sample( $size = 10 )
shuffle( )
skip( $howMany )
some( callable $c )
sortBy( $callback , $dir = \SORT_DESC , $type = \SORT_NUMERIC )
sumOf( $matcher = null )
take( $size = 1 , $from = 0 )
takeLast( $howMany )
through( callable $handler )
toArray( $preserveKeys = true )
toList( )
transpose( )
Cake\Collection\CollectionInterface
unfold( callable $transformer = null )
zip( $items )
zipWith( $items , $callable )
cartesianProduct() |
protected callable
A callable responsible for extracting a single value for each item in the collection.
© 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.ExtractIterator.html