lithium\util\collection\Filters::apply()

public static method

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 $class

    The fully namespaced name of a static class to which the filter will be applied. The class name specified in $class must extend StaticObject, or else statically implement the applyFilter() method.

  • string $method

    The method to which the filter will be applied.

  • \Closure $filter

    The filter to apply to the class method.

Returns

void

Source

	public static function apply($class, $method, $filter) {
		if (class_exists($class, false)) {
			return $class::applyFilter($method, $filter);
		}
		static::$_lazyFilters[$class][$method][] = $filter;
	}