From 7deb1e9b03d5a98adc4c1eed60e6c12eed94a518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 22 Feb 2021 18:12:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Command.php | 21 --------------------- System/Application.php | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/HttpServer/Command.php b/HttpServer/Command.php index d2623664..98837e14 100644 --- a/HttpServer/Command.php +++ b/HttpServer/Command.php @@ -53,28 +53,7 @@ class Command extends \Console\Command return 'shutdown success.'; } - $this->scan_system_annotation(); - return $manager->start(); } - - /** - * @throws ReflectionException - * @throws ComponentException - * @throws NotFindPropertyException - */ - public function scan_system_annotation() - { - $annotation = Snowflake::app()->getAttributes(); - $annotation->readControllers(__DIR__ . '/../Console', 'Console', 'system'); - $annotation->readControllers(__DIR__ . '/../Database', 'Database', 'system'); - $annotation->readControllers(__DIR__ . '/../Gii', 'Gii', 'system'); - $annotation->readControllers(__DIR__ . '/../HttpServer', 'HttpServer', 'system'); - $annotation->readControllers(__DIR__ . '/../Kafka', 'Kafka', 'system'); - $annotation->readControllers(__DIR__ . '/../System', 'Snowflake', 'system'); - $annotation->readControllers(__DIR__ . '/../Validator', 'Validator', 'system'); - } - - } diff --git a/System/Application.php b/System/Application.php index 6c276643..17ce108e 100644 --- a/System/Application.php +++ b/System/Application.php @@ -15,11 +15,14 @@ use Console\ConsoleProviders; use Database\DatabasesProviders; use Exception; use HttpServer\ServerProviders; +use ReflectionException; use Snowflake\Abstracts\BaseApplication; use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Input; use Snowflake\Abstracts\Kernel; +use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; +use Snowflake\Exception\NotFindPropertyException; use stdClass; use Swoole\Timer; @@ -101,6 +104,8 @@ class Application extends BaseApplication public function start(Input $argv): bool|string { try { + $this->scan_system_annotation(); + fire(Event::SERVER_BEFORE_START); $this->set('input', $argv); @@ -120,6 +125,25 @@ class Application extends BaseApplication } } + + /** + * @throws ReflectionException + * @throws ComponentException + * @throws NotFindPropertyException + */ + public function scan_system_annotation() + { + $annotation = Snowflake::app()->getAttributes(); + $annotation->readControllers(__DIR__ . '/../Console', 'Console', 'system'); + $annotation->readControllers(__DIR__ . '/../Database', 'Database', 'system'); + $annotation->readControllers(__DIR__ . '/../Gii', 'Gii', 'system'); + $annotation->readControllers(__DIR__ . '/../HttpServer', 'HttpServer', 'system'); + $annotation->readControllers(__DIR__ . '/../Kafka', 'Kafka', 'system'); + $annotation->readControllers(__DIR__ . '/../System', 'Snowflake', 'system'); + $annotation->readControllers(__DIR__ . '/../Validator', 'Validator', 'system'); + } + + /** * @param $className * @param null $abstracts