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.
Parameters
- string $method The name of the method being executed, usually the value of `__METHOD__`.
- array $params An associative array containing all the parameters passed into the method.
- Closure $callback The method's implementation, wrapped in a closure.
- array $filters Additional filters to apply to the method for this call only.
Returns
mixed Returns the return value of `$callback`, modified by any filters passed in `$filters` or applied with `applyFilter()`.Source
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'));
}