lithium\core\StaticObject::applyFilter PHP Method

applyFilter() public static method

Apply a closure to a method of the current static object.
See also: lithium\core\StaticObject::_filter()
See also: lithium\util\collection\Filters
public static applyFilter ( mixed $method, Closure $filter = null ) : void
$method mixed The name of the method to apply the closure to. Can either be a single method name as a string, or an array of method names. Can also be false to remove all filters on the current object.
$filter Closure The closure that is used to filter the method(s), can also be false to remove all the current filters for the given method.
return void
    public static function applyFilter($method, $filter = null)
    {
        $class = get_called_class();
        if ($method === false) {
            static::$_methodFilters[$class] = array();
            return;
        }
        foreach ((array) $method as $m) {
            if (!isset(static::$_methodFilters[$class][$m]) || $filter === false) {
                static::$_methodFilters[$class][$m] = array();
            }
            if ($filter !== false) {
                static::$_methodFilters[$class][$m][] = $filter;
            }
        }
    }