lithium\data\Collection::map()
Overrides
lithium\util\Collection::map()
Applies a callback to a copy of all data in the collection and returns the result.
Overriden to load any data that has not yet been loaded.
Parameters
-
callback
$filter
The filter to apply.
-
array
$options
The available options are:
'collect'
: Iftrue
, the results will be returned wrapped in a newCollection
object or subclass.
Returns
objectThe filtered data.
Source
public function map($filter, array $options = []) {
$defaults = ['collect' => true];
$options += $defaults;
$this->offsetGet(null);
$data = parent::map($filter, $options);
if ($options['collect']) {
foreach (['_model', '_schema', '_pathKey'] as $key) {
$data->{$key} = $this->{$key};
}
}
return $data;
}