public 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 function applyFilter($method, $filter = null)
{
if ($method === false) {
$this->_methodFilters = array();
return;
}
foreach ((array) $method as $m) {
if (!isset($this->_methodFilters[$m]) || $filter === false) {
$this->_methodFilters[$m] = array();
}
if ($filter !== false) {
$this->_methodFilters[$m][] = $filter;
}
}
}