summaryrefslogtreecommitdiffstats
path: root/system/classes/controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/classes/controller.php')
-rw-r--r--system/classes/controller.php120
1 files changed, 64 insertions, 56 deletions
diff --git a/system/classes/controller.php b/system/classes/controller.php
index a1aff33..df0af7b 100644
--- a/system/classes/controller.php
+++ b/system/classes/controller.php
@@ -1,85 +1,93 @@
-<?php
+<?php
/**
* Base Controller class. Controllers contain the logic of your website,
* each action representing a reply to a particular request, e.g. a single page.
* @package Core
*/
-class Controller {
+class Controller
+{
- /**
- * Request for this controller. Holds all input data.
- * @var Request
- * @access public
- */
+ /**
+ * Request for this controller. Holds all input data.
+ * @var Request
+ * @access public
+ */
public $request;
- /**
- * Response for this controller. It will be updated with headers and
+ /**
+ * Response for this controller. It will be updated with headers and
* response body during controller execution
- * @var Response
- * @access public
- */
+ * @var Response
+ * @access public
+ */
public $response;
- /**
- * If set to False stops controller execution
- * @var boolean
- * @access public
- */
- public $execute=true;
+ /**
+ * If set to False stops controller execution
+ * @var boolean
+ * @access public
+ */
+ public $execute = true;
- /**
- * This method is called before the action.
- * You can override it if you need to,
+ /**
+ * This method is called before the action.
+ * You can override it if you need to,
* it doesn't do anything by default.
- *
- * @return void
- * @access public
- */
- public function before() {}
+ *
+ * @return void
+ * @access public
+ */
+ public function before()
+ {
- /**
- * This method is called after the action.
- * You can override it if you need to,
+ }
+
+ /**
+ * This method is called after the action.
+ * You can override it if you need to,
* it doesn't do anything by default.
- *
- * @return void
- * @access public
- */
- public function after() { }
+ *
+ * @return void
+ * @access public
+ */
+ public function after()
+ {
+
+ }
- /**
- * Creates new Controller
- *
- * @return void
- * @access public
- */
- public function __construct() {
- $this->response=new Response;
+ /**
+ * Creates new Controller
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct()
+ {
+ $this->response = new Response;
}
- /**
- * Runs the appropriate action.
+ /**
+ * Runs the appropriate action.
* It will execute the before() method before the action
* and after() method after the action finishes.
- *
- * @param string $action Name of the action to execute.
- * @return void
- * @access public
- * @throws Exception If the specified action doesn't exist
- */
- public function run($action) {
+ *
+ * @param string $action Name of the action to execute.
+ * @return void
+ * @access public
+ * @throws Exception If the specified action doesn't exist
+ */
+ public function run($action)
+ {
$action = 'action_'.$action;
if (!method_exists($this, $action))
- throw new Exception("Method {$action} doesn't exist in ".get_class($this),404);
- $this->execute=true;
+ throw new Exception("Method {$action} doesn't exist in ".get_class($this), 404);
+ $this->execute = true;
$this->before();
- if($this->execute)
+ if ($this->execute)
$this->$action();
- if($this->execute)
+ if ($this->execute)
$this->after();
}
-
} \ No newline at end of file