From bc863bf39560f769450777cb4baaf6f07b00b48e Mon Sep 17 00:00:00 2001 From: zcmzc <767036228@qq.com> Date: Tue, 25 Jun 2019 20:52:50 +0800 Subject: [PATCH] Added aspect config --- src/di/composer.json | 4 +- src/di/src/ConfigProvider.php | 4 ++ .../src/Listener/BootApplicationListener.php | 57 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/di/src/Listener/BootApplicationListener.php diff --git a/src/di/composer.json b/src/di/composer.json index f70a65cb4..ed5c8ceb0 100644 --- a/src/di/composer.json +++ b/src/di/composer.json @@ -18,7 +18,9 @@ "doctrine/annotations": "^1.6", "symfony/finder": "^4.1", "php-di/phpdoc-reader": "^2.0.1", - "doctrine/instantiator": "^1.0" + "doctrine/instantiator": "^1.0", + "hyperf/event": "~1.0.0", + "hyperf/framework": "~1.0.0" }, "require-dev": { "malukenho/docheader": "^0.1.6", diff --git a/src/di/src/ConfigProvider.php b/src/di/src/ConfigProvider.php index 064cab405..a4bf51e16 100644 --- a/src/di/src/ConfigProvider.php +++ b/src/di/src/ConfigProvider.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Hyperf\Di; use Hyperf\Di\Command\InitProxyCommand; +use Hyperf\Di\Listener\BootApplicationListener; class ConfigProvider { @@ -24,6 +25,9 @@ class ConfigProvider 'commands' => [ InitProxyCommand::class, ], + 'listeners' => [ + BootApplicationListener::class, + ], 'scan' => [ 'paths' => [ __DIR__, diff --git a/src/di/src/Listener/BootApplicationListener.php b/src/di/src/Listener/BootApplicationListener.php new file mode 100644 index 000000000..5b5cd08f2 --- /dev/null +++ b/src/di/src/Listener/BootApplicationListener.php @@ -0,0 +1,57 @@ +container = $container; + } + + /** + * Handle the Event when the event is triggered, all listeners will + * complete before the event is returned to the EventDispatcher. + */ + public function process(object $event) + { + $configs = $this->container->get(ConfigInterface::class)->get('aspects', []); + $aspect = new Aspect(); + foreach ($configs as $config) { + if (is_string($config)) { + $aspect->collectClass($config); + } + } + } +} \ No newline at end of file