lithium\core\Object::_filter PHP Method

_filter() protected method

Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it. This, along with the Filters class, is the core of Lithium's filters system. This system allows you to "reach into" an object's methods which are marked as _filterable_, and intercept calls to those methods, optionally modifying parameters or return values.
See also: lithium\core\Object::applyFilter()
See also: lithium\util\collection\Filters
protected _filter ( string $method, array $params, Closure $callback, array $filters = [] ) : mixed
$method string The name of the method being executed, usually the value of `__METHOD__`.
$params array An associative array containing all the parameters passed into the method.
$callback Closure The method's implementation, wrapped in a closure.
$filters array Additional filters to apply to the method for this call only.
return mixed Returns the return value of `$callback`, modified by any filters passed in `$filters` or applied with `applyFilter()`.
    protected function _filter($method, $params, $callback, $filters = array())
    {
        list($class, $method) = explode('::', $method);
        if (empty($this->_methodFilters[$method]) && empty($filters)) {
            return $callback($this, $params, null);
        }
        $f = isset($this->_methodFilters[$method]) ? $this->_methodFilters[$method] : array();
        $data = array_merge($f, $filters, array($callback));
        return Filters::run($this, $params, compact('data', 'class', 'method'));
    }