CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.0 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.0
      • 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

  • Cake
    • Auth
    • Cache
      • Engine
    • Collection
      • Iterator
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
      • Formatter
      • Parser
    • Log
      • Engine
    • Network
      • Email
      • Exception
      • Http
        • Adapter
        • Auth
        • FormData
      • Session
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Rule
    • Routing
      • Exception
      • Filter
      • Route
    • Shell
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • BufferedIterator
  • ExtractIterator
  • FilterIterator
  • InsertIterator
  • MapReduce
  • NestIterator
  • NoChildrenIterator
  • ReplaceIterator
  • SortIterator
  • TreeIterator
  • TreePrinter
  • ZipIterator

Class ExtractIterator

Creates an iterator from another iterator that extract the requested column or property based on a path

IteratorIterator implements Iterator, Traversable, OuterIterator
Extended by Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
Extended by Cake\Collection\Iterator\ExtractIterator
Namespace: Cake\Collection\Iterator
Location: Collection/Iterator/ExtractIterator.php

Properties summary

  • $_extractor protected
    callable

    A callable responsible for extracting a single value for each item in the collection.

Method Summary

  • __construct() public

    Creates the iterator that will return the requested property for each value in the collection expressed in $path

  • current() public

    Returns the column value defined in $path or null if the path could not be followed

Method Detail

__construct() public ¶

__construct( array|Traversable $items , string $path )

Creates the iterator that will return the requested property for each value in the collection expressed in $path

Example:

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'');
Parameters
array|Traversable $items
The list of values to iterate
string $path

a dot separated string symbolizing the path to follow inside the hierarchy of each value so that the column can be extracted.

Throws
InvalidArgumentException
If passed incorrect type for items.
Overrides
Cake\Collection\Collection::__construct()

current() public ¶

current( )

Returns the column value defined in $path or null if the path could not be followed

Returns
mixed
Overrides
IteratorIterator::current()

Methods inherited from Cake\Collection\Collection

__debugInfo() public ¶

__debugInfo( )

Returns an array that can be used to describe the internal state of this object.

Returns
array

serialize() public ¶

serialize( )

Returns a string representation of this object that can be used to reconstruct it

Returns
string
Implementation of
Serializable::serialize()

unserialize() public ¶

unserialize( string $collection )

Unserializes the passed string and rebuilds the Collection instance

Parameters
string $collection
The serialized collection
Implementation of
Serializable::unserialize()

Methods used from Cake\Collection\CollectionTrait

_unwrap() public ¶

_unwrap( )

Backwards compatible wrapper for unwrap()

Deprecated
Returns
Iterator

append() public ¶

append( $items )

buffered() public ¶

buffered( )

Returns
Cake\Collection\Iterator\BufferedIterator

combine() public ¶

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

compile() public ¶

compile( $preserveKeys true )

contains() public ¶

contains( $value )

countBy() public ¶

countBy( $callback )

each() public ¶

each( callable $c )

every() public ¶

every( callable $c )

extract() public ¶

extract( $matcher )

filter() public ¶

filter( callable $c null )

Returns
Cake\Collection\Iterator\FilterIterator

first() public ¶

first( )

firstMatch() public ¶

firstMatch( array $conditions )

groupBy() public ¶

groupBy( $callback )

indexBy() public ¶

indexBy( $callback )

insert() public ¶

insert( $path , $values )

Returns
Cake\Collection\Iterator\InsertIterator

isEmpty() public ¶

isEmpty( )

jsonSerialize() public ¶

jsonSerialize( )

last() public ¶

last( )

listNested() public ¶

listNested( $dir 'desc' , $nestingKey 'children' )

Returns
Cake\Collection\Iterator\TreeIterator

map() public ¶

map( callable $c )

Returns
Cake\Collection\Iterator\ReplaceIterator

match() public ¶

match( array $conditions )

max() public ¶

max( $callback , $type SORT_NUMERIC )

min() public ¶

min( $callback , $type SORT_NUMERIC )

nest() public ¶

nest( $idPath , $parentPath )

reduce() public ¶

reduce( callable $c , $zero null )

reject() public ¶

reject( callable $c )

Returns
Cake\Collection\Iterator\FilterIterator

sample() public ¶

sample( $size 10 )

shuffle() public ¶

shuffle( )

skip() public ¶

skip( $howMany )

some() public ¶

some( callable $c )

sortBy() public ¶

sortBy( $callback , $dir SORT_DESC , $type SORT_NUMERIC )

stopWhen() public ¶

stopWhen( $condition )

Returns
Cake\Collection\Iterator\StoppableIterator

sumOf() public ¶

sumOf( $matcher null )

take() public ¶

take( $size 1 , $from 0 )

through() public ¶

through( callable $handler )

toArray() public ¶

toArray( $preserveKeys true )

toList() public ¶

toList( )

unfold() public ¶

unfold( callable $transformer null )

unwrap() public ¶

unwrap( )

zip() public ¶

zip( $items )

zipWith() public ¶

zipWith( $items , $callable )

Properties detail

$_extractor ¶

protected callable

A callable responsible for extracting a single value for each item in the collection.

Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs