lithium\util\collection\Filters::apply()
Lazily applies a filter to a method of a static class.
This method is useful if you want to apply a filter inside a global bootstrap file to a static class which may or may not be loaded during every request, or which may be loaded lazily elsewhere in your application. If the class is already loaded, the filter will be applied immediately.
However, if the class has not been loaded, the filter will be stored and applied to the class
the first time the method specified in $method is called. This works for any class which
extends StaticObject.
Parameters
-
string
$classThe fully namespaced name of a static class to which the filter will be applied. The class name specified in
$classmust extendStaticObject, or else statically implement theapplyFilter()method. -
string
$methodThe method to which the filter will be applied.
-
\Closure
$filterThe filter to apply to the class method.
Returns
voidSource
public static function apply($class, $method, $filter) {
if (class_exists($class, false)) {
return $class::applyFilter($method, $filter);
}
static::$_lazyFilters[$class][$method][] = $filter;
}