Completed
Push — master ( 3c1e11...7d78ad )
by
unknown
37:34
created

JobCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace SfCod\QueueBundle\DependencyInjection\Compiler;
4
5
use SfCod\QueueBundle\Service\JobQueue;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
9
/**
10
 * Class JobCompilerPass
11
 * @author Virchenko Maksim <[email protected]>
12
 * @package SfCod\QueueBundle\DependencyInjection\Compiler
13
 */
14
class JobCompilerPass implements CompilerPassInterface
15
{
16
    /**
17
     * Find all job handlers and mark them as public in case to work properly with job queue
18
     *
19
     * @param ContainerBuilder $container
20
     */
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->has(JobQueue::class)) {
24
            return;
25
        }
26
27
        $taggedServices = $container->findTaggedServiceIds('sfcod.jobqueue.job');
28
29
        foreach ($taggedServices as $id => $tags) {
30
            $definition = $container->findDefinition($id);
31
            $definition->setPublic(true);
32
        }
33
    }
34
}