lithium\data\Collection::find PHP Method

find() public method

Overrides parent find() implementation to enable key/value-based filtering of entity objects contained in this collection.
public find ( mixed $filter, array $options = [] ) : mixed
$filter mixed Callback to use for filtering, or array of key/value pairs which entity properties will be matched against.
$options array Options to modify the behavior of this method. See the documentation for the `$options` parameter of `lithium\util\Collection::find()`.
return mixed The filtered items. Will be an array unless `'collect'` is defined in the `$options` argument, then an instance of this class will be returned.
    public function find($filter, array $options = array())
    {
        $this->offsetGet(null);
        if (is_array($filter)) {
            $filter = $this->_filterFromArray($filter);
        }
        return parent::find($filter, $options);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Filters a copy of the items in the collection.
  *
  * Overridden to load any data that has not yet been loaded.
  *
  * @param callback $filter Callback to use for filtering.
  * @param array $options The available options are:
  *              - `'collect'`: If `true`, the results will be returned wrapped
  *              in a new `Collection` object or subclass.
  * @return mixed The filtered items. Will be an array unless `'collect'` is defined in the
  * `$options` argument, then an instance of this class will be returned.
  */
 public function find($filter, array $options = array())
 {
     $this->offsetGet(null);
     return parent::find($filter, $options);
 }