Completed
Push — master ( e02161...971421 )
by Matthew
12:50
created

BeanstalkdCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 13
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class BeanstalkdCompilerPass implements CompilerPassInterface
11
{
12
    public function process(ContainerBuilder $container)
13
    {
14
        if ($container->hasParameter('dtc_queue.beanstalkd.host')) {
15
            $definition = new Definition('Pheanstalk\\Pheanstalk',
16
                [$container->getParameter('dtc_queue.beanstalkd.host')]);
17
            $container->setDefinition('dtc_queue.beanstalkd', $definition);
18
            $definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd');
19
            $definition->addMethodCall('setBeanstalkd', [new Reference('dtc_queue.beanstalkd')]);
20
            if ($container->hasParameter('dtc_queue.beanstalkd.tube')) {
21
                $definition->addMethodCall('setTube', [$container->getParameter('dtc_queue.beanstalkd.tube')]);
22
            }
23
        }
24
    }
25
}
26