From 0affc404fddaf8822486ec3792bdfdc3e7222218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 8 Apr 2021 11:24:31 +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 --- System/Application.php | 8 ++++++-- function.php | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/System/Application.php b/System/Application.php index 2c54bf2f..2fe41b8b 100644 --- a/System/Application.php +++ b/System/Application.php @@ -10,13 +10,12 @@ declare(strict_types=1); namespace Snowflake; -use Annotation\Aspect; use Closure; use Console\Console; use Console\ConsoleProviders; use Database\DatabasesProviders; -use Database\InjectProperty; use Exception; +use HttpServer\Command; use HttpServer\ServerProviders; use Snowflake\Abstracts\BaseApplication; use Snowflake\Abstracts\Config; @@ -26,6 +25,7 @@ use Snowflake\Crontab\CrontabProviders; use Snowflake\Exception\NotFindClassException; use stdClass; use Swoole\Timer; +use Wchat\WchatProviders; /** * Class Init @@ -33,6 +33,7 @@ use Swoole\Timer; * @package Snowflake * * @property-read Config $config + * @property-read WchatProviders $wchat */ class Application extends BaseApplication { @@ -141,6 +142,9 @@ class Application extends BaseApplication $manager->register(Runtime::class); $manager->setParameters($argv); $class = $manager->search(); + if (!($class instanceof Command)) { + scan_directory(APP_PATH, 'APP'); + } response()->send($manager->execCommand($class)); } catch (\Throwable $exception) { response()->send(implode("\n", [ diff --git a/function.php b/function.php index 7326ca5d..89897a22 100644 --- a/function.php +++ b/function.php @@ -80,6 +80,22 @@ if (!function_exists('annotation')) { } +if (!function_exists('scan_directory')) { + + + /** + * @param $dir + * @param $namespace + * @throws Exception + */ + function scan_directory($dir, $namespace) + { + \annotation()->read($dir, $namespace); + } + +} + + if (!function_exists('swoole')) { @@ -312,8 +328,7 @@ if (!function_exists('redis')) { /** - * @param string $messages - * @param string $category + * @return \Snowflake\Cache\Redis|Redis * @throws Exception */ function redis(): \Snowflake\Cache\Redis|Redis