Conditions | 8 |
Paths | 13 |
Total Lines | 36 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function process(ContainerBuilder $container) |
||
12 | { |
||
13 | if (!$container->hasDefinition('tactician_domain_events.command.debug')) { |
||
14 | return; |
||
15 | } |
||
16 | |||
17 | $command = $container->getDefinition('tactician_domain_events.command.debug'); |
||
18 | $subscribers = $container->findTaggedServiceIds('tactician.event_subscriber'); |
||
19 | $listeners = $container->findTaggedServiceIds('tactician.event_listener'); |
||
20 | |||
21 | $events = []; |
||
22 | |||
23 | foreach ($listeners as $serviceId => $tags) { |
||
24 | foreach ($tags as $tag) { |
||
25 | $listener = $container->getDefinition($serviceId); |
||
26 | $method = array_key_exists('method', $tag) ? $tag['method'] : '__invoke'; |
||
27 | |||
28 | $events[$tag['event']][] = $listener->getClass() . '::' . $method; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | foreach ($subscribers as $serviceId => $tags) { |
||
33 | $subscriber = $container->get($serviceId); |
||
34 | |||
35 | if (!$subscriber instanceof EventSubscriberInterface) { |
||
36 | continue; |
||
37 | } |
||
38 | |||
39 | foreach ($subscriber->getSubscribedEvents() as $event => $method) { |
||
40 | $events[$event][] = get_class($subscriber) . '::' . $method[1]; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | ksort($events); |
||
45 | $command->setArgument(0, $events); |
||
46 | } |
||
47 | } |
||
48 |