This commit is contained in:
2020-11-10 18:04:42 +08:00
parent 6cb8172b56
commit 2e04f5a9b7
+26 -9
View File
@@ -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);
}
}