lithium\aop\Filters::clear()

public static method

Clears filters optionally constrained by class or class and method combination.

To clear filters for all methods of static class:

Filters::clear('Foo');

To clear instance and class filters for all methods of concrete class, or to clear just the instance filters for all methods:

Filters::clear('Bar');
Filters::clear($instance);

This method involves some overhead. This is neglectable as it isn't commonly called in hot code paths.

Parameters

  • string|object $class

    Fully namespaced class name or an instance of a class.

  • string $method

    The method name i.e. 'bar'.

Returns

void

Source

	public static function clear($class = null, $method = null) {
		if ($class === null && $method === null) {
			static::$_filters = static::$_chains = [];
			return;
		}

		if (is_string($class)) {
			$regex  = '^<' . str_replace('\\', '\\\\', ltrim($class, '\\')) . '.*>';
		} else {
			$regex  = '^<.*#' . spl_object_hash($class) . '>';
		}
		if ($method) {
			$regex .= "::{$method}$";
		}
		foreach (preg_grep("/{$regex}/", array_keys(static::$_filters)) as $id) {
			unset(static::$_filters[$id]);
		}
		foreach (preg_grep("/{$regex}/", array_keys(static::$_chains)) as $id) {
			unset(static::$_chains[$id]);
		}
	}