Trait CollectionTrait
Offers a handful of method to manipulate iterators
- Cake\Collection\CollectionTrait uses Cake\Collection\ExtractTrait
Direct Known Users
Cake\Collection\Collection, Cake\Collection\Iterator\TreeIterator, Cake\Collection\Iterator\TreePrinter, Cake\Collection\Iterator\ZipIterator, Cake\ORM\ResultSetIndirect Known Users
Cake\Collection\Iterator\BufferedIterator, Cake\Collection\Iterator\ExtractIterator, Cake\Collection\Iterator\FilterIterator, Cake\Collection\Iterator\InsertIterator, Cake\Collection\Iterator\NestIterator, Cake\Collection\Iterator\NoChildrenIterator, Cake\Collection\Iterator\ReplaceIterator, Cake\Collection\Iterator\SortIterator, Cake\Datasource\ResultSetDecoratorMethod Detail
_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
© 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.CollectionTrait.html