This commit is contained in:
2021-09-07 11:44:12 +08:00
parent 0cdb8c5b20
commit 86880f8b1f
5 changed files with 11 additions and 17 deletions
+1 -2
View File
@@ -373,7 +373,7 @@ abstract class BaseApplication extends Component
*/
public function getRouter(): Router
{
return $this->get('router');
return Kiri::getDi()->get(Router::class);
}
@@ -467,7 +467,6 @@ abstract class BaseApplication extends Component
'config' => ['class' => Config::class],
'logger' => ['class' => Logger::class],
'annotation' => ['class' => SAnnotation::class],
'router' => ['class' => Router::class],
'redis' => ['class' => Redis::class],
'databases' => ['class' => Connection::class],
'aop' => ['class' => AspectManager::class],
+1 -3
View File
@@ -1006,7 +1006,7 @@ if (!function_exists('router')) {
*/
function router(): Router
{
return Kiri::app()->getRouter();
return Kiri::getDi()->get(Router::class);
}
}
@@ -1018,8 +1018,6 @@ if (!function_exists('isService')) {
/**
* @param string $name
* @return bool
* @throws NotFindClassException
* @throws ReflectionException
*/
function isService(string $name): bool
{
+2 -2
View File
@@ -76,7 +76,7 @@ class Router extends HttpService implements RouterInterface
*/
public static function getNamespace(): string
{
$router = Kiri::app()->getRouter();
$router = Kiri::getDi()->get(Router::class);
return Config::get('http.namespace', $router->namespace);
}
@@ -96,7 +96,7 @@ class Router extends HttpService implements RouterInterface
* @param $handler
* @param string $method
* @return ?Node
* @throws Exception
* @throws
*/
public function addRoute($path, $handler, string $method = 'any'): ?Node
{
+1 -1
View File
@@ -48,7 +48,7 @@ class OnWorkerStart implements EventDispatcherInterface
$this->interpretDirectory($isWorker);
if ($isWorker) {
ServerManager::setEnv('environmental', Kiri::WORKER);
Kiri::getFactory()->getRouter()->_loader();
Kiri::getDi()->get(Router::class)->_loader();
$this->setProcessName(sprintf('Worker[%d].%d', $event->server->worker_pid, $event->workerId));
} else {
+6 -9
View File
@@ -23,18 +23,15 @@ use Kiri\Kiri;
}
/**
* @param static $params
* @param mixed $class
* @param mixed|null $method
* @return Router
* @throws \Kiri\Exception\NotFindClassException
* @throws \ReflectionException
*/
/**
* @param mixed $class
* @param mixed|null $method
* @return Router
*/
public function execute(mixed $class, mixed $method = null): Router
{
// TODO: Implement setHandler() method.
$router = Kiri::app()->getRouter();
$router = Kiri::getDi()->get(Router::class);
if (is_string($class)) {
$class = di($class);
}