lithium\util\collection\Filters::hasApplied PHP Method

hasApplied() public static method

If a filter has been lazily applied (using Filters::apply()) to a class which is/was not yet loaded, checks to see if the filter is still being held, or has been applied. The filter will not be applied until the method being filtered has been called.
See also: lithium\util\collection\Filters::apply()
public static hasApplied ( string $class, string $method ) : boolean
$class string Fully-namespaced class name.
$method string Method name.
return boolean
    public static function hasApplied($class, $method)
    {
        return isset(static::$_lazyFilters[$class][$method]);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 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.
  *
  * @see lithium\util\collection\Filters
  * @param string|array $method The name of the method being executed, or an array containing
  *        the name of the class that defined the method, and the method name.
  * @param array $params An associative array containing all the parameters passed into
  *        the method.
  * @param Closure $callback The method's implementation, wrapped in a closure.
  * @param array $filters Additional filters to apply to the method for this call only.
  * @return mixed
  */
 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'));
 }