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

EventCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
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