Completed
Push — master ( 8cd050...5f288c )
by Andreas
22:58
created

indexerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 15
ccs 10
cts 10
cp 1
crap 3
rs 9.9666
1
<?php
2
namespace midcom\bundle\dependencyInjection;
3
4
use Symfony\Component\DependencyInjection\ContainerBuilder;
5
use Symfony\Component\DependencyInjection\Reference;
6
7
class indexerPass extends configPass
8
{
9 1
    public function process(ContainerBuilder $container)
10
    {
11 1
        if ($class = $this->config->get('indexer_backend')) {
12 1
            if (strpos($class, '_') === false) {
13
                // Built-in backend called using the shorthand notation
14 1
                $class = "midcom_services_indexer_backend_" . $class;
15
            }
16
17 1
            $backend = $container->getDefinition('indexer.backend');
18 1
            $backend->setClass($class);
19 1
            $indexer = $container->getDefinition('indexer');
20 1
            $indexer->addArgument(new Reference('indexer.backend'));
21
22 1
            $container->getDefinition('event_dispatcher')
23 1
                ->addMethodCall('addSubscriber', [new Reference('indexer')]);
24
        }
25
    }
26
}