name = $name;
$this->filters = Filter::parse($filters);
}
/**
* Determine if this collection's filters apply to a given method.
*
* @param string $method
* @return bool
*/
public function applies($method)
{
if (count($this->only) > 0 and ! in_array($method, $this->only))
{
return false;
}
if (count($this->except) > 0 and in_array($method, $this->except))
{
return false;
}
return true;
}
/**
* Set the excluded controller methods.
*
* When methods are excluded, the collection's filters will be run for each
* controller method except those explicitly specified via this method.
*
*
* // Specify a filter for all methods except "index"
* $this->filter('before', 'auth')->except('index');
*
* // Specify a filter for all methods except "index" and "home"
* $this->filter('before', 'auth')->except(array('index', 'home'));
*
*
* @param array $methods
* @return Filter_Collection
*/
public function except($methods)
{
$this->except = (array) $methods;
return $this;
}
/**
* Set the included controller methods.
*
* This method is the inverse of the "except" methods. The methods specified
* via this method are the only controller methods on which the collection's
* filters will be run.
*
*
* // Specify a filter for only the "index" method
* $this->filter('before', 'auth')->only('index');
*
* // Specify a filter for only the "index" and "home" methods
* $this->filter('before', 'auth')->only(array('index', 'home'));
*
*
* @param array $methods
* @return Filter_Collection
*/
public function only($methods)
{
$this->only = (array) $methods;
return $this;
}
}