Completed
Push — master ( 57a73d...51c7de )
by Alexey
38:40
created

EventCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
1
<?php
2
3
namespace SfCod\SocketIoBundle\DependencyInjection\Compiler;
4
5
use SfCod\QueueBundle\Base\JobResolverInterface;
6
use SfCod\QueueBundle\Service\JobQueue;
7
use SfCod\SocketIoBundle\Service\EventManager;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
/**
13
 * Class EventCompilerPass
14
 */
15
class EventCompilerPass implements CompilerPassInterface
16
{
17
    /**
18
     * Find all job handlers and mark them as public in case to work properly with job queue
19
     *
20
     * @param ContainerBuilder $container
21
     */
22
    public function process(ContainerBuilder $container)
23
    {
24
        $eventManager = $container->getDefinition(EventManager::class);
25
        $taggedServices = $container->findTaggedServiceIds('sfcod.socketio.event');
26
27
        foreach ($taggedServices as $id => $tags) {
28
            $eventManager->addMethodCall('addEvent', [new Reference($id)]);
29
        }
30
    }
31
}
32