diff --git a/HttpServer/Controller.php b/HttpServer/Controller.php index 2bfc6e13..8be68454 100644 --- a/HttpServer/Controller.php +++ b/HttpServer/Controller.php @@ -9,13 +9,13 @@ use HttpServer\Http\HttpParams; use HttpServer\Http\Request; use Exception; use Snowflake\Abstracts\BaseGoto; +use Snowflake\Exception\ComponentException; use Snowflake\Snowflake; /** * Class WebController * @package Snowflake\Snowflake\Web * @property BaseGoto $goto - * @property \Snowflake\Application $app */ class Controller extends Application { @@ -32,16 +32,12 @@ class Controller extends Application public Request $request; - public BaseGoto $goto; - - - public $app; - - + /** + * Controller constructor. + * @param array $config + */ public function __construct($config = []) { - $this->app = Snowflake::app(); - $this->goto = $this->app->goto; parent::__construct($config); } @@ -106,4 +102,25 @@ class Controller extends Application } + /** + * @param $methods + * @return mixed + * @throws ComponentException + */ + public function __get($methods) + { + // TODO: Change the autogenerated stub + if (property_exists($this, $methods)) { + return $this->$methods; + } + + $method = 'get' . ucfirst($methods); + if (method_exists($this, $method)) { + return $this->{$method}(); + } + + return Snowflake::app()->get($methods); + } + + }