Completed
Branch master (38bcb9)
by Matthew
02:36
created

BeanstalkdCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 18
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
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(
16
                'Pheanstalk\\Pheanstalk',
17
                [$container->getParameter('dtc_queue.beanstalkd.host')]
18
            );
19
            $container->setDefinition('dtc_queue.beanstalkd', $definition);
20
            $definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd');
21
            $definition->addMethodCall('setBeanstalkd', [new Reference('dtc_queue.beanstalkd')]);
22
            if ($container->hasParameter('dtc_queue.beanstalkd.tube')) {
23
                $definition->addMethodCall('setTube', [$container->getParameter('dtc_queue.beanstalkd.tube')]);
24
            }
25
        }
26
    }
27
}
28