Code style fixes
This commit is contained in:
parent
5371b8fc75
commit
5b9c1d32f1
16 changed files with 1219 additions and 1360 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace b8;
|
||||
|
||||
use b8\Config;
|
||||
use b8\Http\Request;
|
||||
use b8\Http\Response;
|
||||
use b8\View;
|
||||
|
|
@ -13,104 +12,104 @@ use b8\View;
|
|||
*/
|
||||
abstract class Controller
|
||||
{
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
/**
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
protected $controllerView;
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
protected $controllerView;
|
||||
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
protected $view;
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
public function __construct(Config $config, Request $request, Response $response)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
public function __construct(Config $config, Request $request, Response $response)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function hasAction($name)
|
||||
{
|
||||
if (method_exists($this, $name)) {
|
||||
return true;
|
||||
}
|
||||
public function hasAction($name)
|
||||
{
|
||||
if (method_exists($this, $name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method_exists($this, '__call')) {
|
||||
return true;
|
||||
}
|
||||
if (method_exists($this, '__call')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an action on this controller and returns a Response object.
|
||||
* @return Response
|
||||
*/
|
||||
public function handleAction($action, $actionParams)
|
||||
{
|
||||
return call_user_func_array(array($this, $action), $actionParams);
|
||||
}
|
||||
/**
|
||||
* Handles an action on this controller and returns a Response object.
|
||||
* @return Response
|
||||
*/
|
||||
public function handleAction($action, $actionParams)
|
||||
{
|
||||
return call_user_func_array([$this, $action], $actionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the controller.
|
||||
*/
|
||||
abstract public function init();
|
||||
/**
|
||||
* Initialise the controller.
|
||||
*/
|
||||
abstract public function init();
|
||||
|
||||
/**
|
||||
* Get a hash of incoming request parameters ($_GET, $_POST)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->request->getParams();
|
||||
}
|
||||
/**
|
||||
* Get a hash of incoming request parameters ($_GET, $_POST)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->request->getParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific incoming request parameter.
|
||||
*
|
||||
* @param $key
|
||||
* @param mixed $default Default return value (if key does not exist)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParam($key, $default = null)
|
||||
{
|
||||
return $this->request->getParam($key, $default);
|
||||
}
|
||||
/**
|
||||
* Get a specific incoming request parameter.
|
||||
*
|
||||
* @param $key
|
||||
* @param mixed $default Default return value (if key does not exist)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParam($key, $default = null)
|
||||
{
|
||||
return $this->request->getParam($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of an incoming request parameter.
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function setParam($key, $value)
|
||||
{
|
||||
return $this->request->setParam($key, $value);
|
||||
}
|
||||
/**
|
||||
* Change the value of an incoming request parameter.
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function setParam($key, $value)
|
||||
{
|
||||
return $this->request->setParam($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an incoming request parameter.
|
||||
* @param $key
|
||||
*/
|
||||
public function unsetParam($key)
|
||||
{
|
||||
return $this->request->unsetParam($key);
|
||||
}
|
||||
/**
|
||||
* Remove an incoming request parameter.
|
||||
* @param $key
|
||||
*/
|
||||
public function unsetParam($key)
|
||||
{
|
||||
return $this->request->unsetParam($key);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue