Passed
Push — master ( 482ae9...59f703 )
by Andreas
22:54
created

indexerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

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