mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-03 12:17:48 +08:00
Added aspect config
This commit is contained in:
parent
02c14f46d8
commit
bc863bf395
@ -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",
|
||||
|
@ -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__,
|
||||
|
57
src/di/src/Listener/BootApplicationListener.php
Normal file
57
src/di/src/Listener/BootApplicationListener.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.io
|
||||
* @document https://doc.hyperf.io
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Hyperf\Di\Listener;
|
||||
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Di\Annotation\Aspect;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BootApplication;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class BootApplicationListener implements ListenerInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @return string[] returns the events that you want to listen
|
||||
*/
|
||||
public function listen(): array
|
||||
{
|
||||
return [
|
||||
BootApplication::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user