refactoring various classes.
This commit is contained in:
@@ -15,6 +15,13 @@ abstract class Controller {
|
||||
*/
|
||||
public $layout;
|
||||
|
||||
/**
|
||||
* Indicates if the controller uses RESTful routing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $restful = false;
|
||||
|
||||
/**
|
||||
* The filters assigned to the controller.
|
||||
*
|
||||
@@ -125,7 +132,19 @@ abstract class Controller {
|
||||
|
||||
if (is_null($response))
|
||||
{
|
||||
$response = call_user_func_array(array($this, "action_{$method}"), $parameters);
|
||||
// The developer may mark the controller as being "RESTful" which
|
||||
// indicates that the controller actions are prefixed with the
|
||||
// HTTP verb they respond to rather than the word "action".
|
||||
if ($this->restful)
|
||||
{
|
||||
$action = strtolower(Request::method()).'_'.$method;
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = "action_{$method}";
|
||||
}
|
||||
|
||||
$response = call_user_func_array(array($this, $action), $parameters);
|
||||
|
||||
// If the controller has specified a layout view. The response
|
||||
// returned by the controller method will be bound to that view
|
||||
|
||||
@@ -160,7 +160,7 @@ class Filter_Collection {
|
||||
* $this->filter('before', 'auth')->except('index');
|
||||
*
|
||||
* // Specify a filter for all methods except "index" and "home"
|
||||
* $this->filter('before', 'auth')->except(array('index', 'home'));
|
||||
* $this->filter('before', 'auth')->except('index', 'home');
|
||||
* </code>
|
||||
*
|
||||
* @param array $methods
|
||||
@@ -168,7 +168,7 @@ class Filter_Collection {
|
||||
*/
|
||||
public function except($methods)
|
||||
{
|
||||
$this->except = (array) $methods;
|
||||
$this->except = (count(func_get_args()) > 1) ? func_get_args() : (array) $methods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class Filter_Collection {
|
||||
* $this->filter('before', 'auth')->only('index');
|
||||
*
|
||||
* // Specify a filter for only the "index" and "home" methods
|
||||
* $this->filter('before', 'auth')->only(array('index', 'home'));
|
||||
* $this->filter('before', 'auth')->only('index', 'home');
|
||||
* </code>
|
||||
*
|
||||
* @param array $methods
|
||||
@@ -192,7 +192,7 @@ class Filter_Collection {
|
||||
*/
|
||||
public function only($methods)
|
||||
{
|
||||
$this->only = (array) $methods;
|
||||
$this->only = (count(func_get_args()) > 1) ? func_get_args() : (array) $methods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ class Filter_Collection {
|
||||
* $this->filter('before', 'csrf')->on('post');
|
||||
*
|
||||
* // Specify that a filter applies for multiple HTTP request methods
|
||||
* $this->filter('before', 'csrf')->on(array('post', 'put'));
|
||||
* $this->filter('before', 'csrf')->on('post', 'put');
|
||||
* </code>
|
||||
*
|
||||
* @param array $methods
|
||||
@@ -216,7 +216,13 @@ class Filter_Collection {
|
||||
*/
|
||||
public function on($methods)
|
||||
{
|
||||
$this->methods = array_map('strtolower', (array) $methods);
|
||||
$methos = (count(func_get_args()) > 1) ? func_get_args() : (array) $methods;
|
||||
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
$this->methods[] = strtolower($method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user