lithium\core\StaticObject::_filter()

protected static 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.

Parameters

  • string $method

    The name of the method being executed.

  • 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

Source

	protected static function _filter($method, $params, $callback, $filters = array()) {
		$class = get_called_class();
		$hasNoFilters = empty(static::$_methodFilters[$class][$method]);

		if ($hasNoFilters && !$filters && !Filters::hasApplied($class, $method)) {
			return $callback($class, $params, null);
		}
		if (!isset(static::$_methodFilters[$class][$method])) {
			static::$_methodFilters += array($class => array());
			static::$_methodFilters[$class][$method] = array();
		}
		$data = array_merge(static::$_methodFilters[$class][$method], $filters, array($callback));
		return Filters::run($class, $params, compact('data', 'class', 'method'));
	}