lithium\util\Collection::each PHP Method

each() public method

Applies a callback to all items in the collection.
public each ( callback $filter ) : Collection
$filter callback The filter to apply.
return Collection This collection instance.
    public function each($filter)
    {
        $this->_data = array_map($filter, $this->_data);
        return $this;
    }

Usage Example

Esempio n. 1
0
 public function schema()
 {
     $data = Libraries::locate('models');
     $models = new Collection(compact('data'));
     if ($this->request->is('json')) {
         $models->each(function ($model) {
             $schema = is_callable(array($model, 'schema')) ? $model::schema() : array();
             return array($model => $schema ? $schema->fields() : array());
         });
     }
     return compact('models');
 }
All Usage Examples Of lithium\util\Collection::each