@@ 8-30 (lines=23) @@ | ||
5 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7 | ||
8 | class CommandBusCompilerPass implements CompilerPassInterface |
|
9 | { |
|
10 | /** |
|
11 | * You can modify the container here before it is dumped to PHP code. |
|
12 | * |
|
13 | * @param ContainerBuilder $container |
|
14 | */ |
|
15 | public function process(ContainerBuilder $container) |
|
16 | { |
|
17 | if (!$container->has('command.bus')) { |
|
18 | return; |
|
19 | } |
|
20 | ||
21 | $commandBus = $container->findDefinition('bus.options.resolver'); |
|
22 | $commandHandlers = $container->findTaggedServiceIds('command_handler'); |
|
23 | ||
24 | foreach ($commandHandlers as $id => $tags) { |
|
25 | foreach ($tags as $attributes) { |
|
26 | $commandBus->addMethodCall('addOption', [$attributes['handles'], $id]); |
|
27 | } |
|
28 | } |
|
29 | } |
|
30 | } |
|
31 |
@@ 8-30 (lines=23) @@ | ||
5 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7 | ||
8 | class QueryBusCompilerPass implements CompilerPassInterface |
|
9 | { |
|
10 | /** |
|
11 | * You can modify the container here before it is dumped to PHP code. |
|
12 | * |
|
13 | * @param ContainerBuilder $container |
|
14 | */ |
|
15 | public function process(ContainerBuilder $container) |
|
16 | { |
|
17 | if (!$container->has('query.bus')) { |
|
18 | return; |
|
19 | } |
|
20 | ||
21 | $queryBus = $container->findDefinition('bus.options.resolver'); |
|
22 | $queryHandlers = $container->findTaggedServiceIds('query_handler'); |
|
23 | ||
24 | foreach ($queryHandlers as $id => $tags) { |
|
25 | foreach ($tags as $attributes) { |
|
26 | $queryBus->addMethodCall('addOption', [$attributes['handles'], $id]); |
|
27 | } |
|
28 | } |
|
29 | } |
|
30 | } |
|
31 |