This commit is contained in:
2020-09-10 15:49:42 +08:00
parent 03f20ae4e3
commit 6271e8d47a
3 changed files with 36 additions and 1 deletions
+6
View File
@@ -99,6 +99,12 @@ class Controller extends Application
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
return $this->$method(); return $this->$method();
} }
$app = Snowflake::app();
if ($app->has($name)) {
return $app->get($name);
}
return parent::__get($name); return parent::__get($name);
} }
+3 -1
View File
@@ -45,6 +45,7 @@ use Database\DatabasesProviders;
* @property Memcached $memcached * @property Memcached $memcached
* @property Logger $logger * @property Logger $logger
* @property Jwt $jwt * @property Jwt $jwt
* @property BaseGoto $goto
*/ */
abstract class BaseApplication extends Service abstract class BaseApplication extends Service
{ {
@@ -371,7 +372,8 @@ abstract class BaseApplication extends Service
'logger' => ['class' => Logger::class], 'logger' => ['class' => Logger::class],
'router' => ['class' => Router::class], 'router' => ['class' => Router::class],
'redis' => ['class' => Redis::class], 'redis' => ['class' => Redis::class],
'jwt' => ['class' => Jwt::class] 'jwt' => ['class' => Jwt::class],
'goto' => ['class' => BaseGoto::class]
]); ]);
} }
} }
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Snowflake\Abstracts;
use Exception;
use HttpServer\Exception\ExitException;
/**
* Class BaseGoto
* @package Snowflake\Abstracts
*/
class BaseGoto extends Component
{
/**
* @param $message
* @param int $statusCode
* @throws Exception
*/
public function end($message, $statusCode = 200)
{
throw new ExitException($message, $statusCode);
}
}