Completed
Push — develop ( b74491...9e8dd2 )
by
unknown
12:13
created

ConverterCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Bundle\ArticleBundle\DependencyInjection;
13
14
use Sulu\Bundle\ArticleBundle\Elasticsearch\EventAwareConverter;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * Replaces class and add argument for replaced service "es.result_converter".
21
 */
22
class ConverterCompilerPass implements CompilerPassInterface
23
{
24
    const SERVICE_ID = 'es.result_converter';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function process(ContainerBuilder $container)
30
    {
31
        if (!$container->hasDefinition(self::SERVICE_ID)) {
32
            return;
33
        }
34
35
        $definition = $container->getDefinition(self::SERVICE_ID);
36
        $definition->setClass(EventAwareConverter::class);
37
        $definition->addArgument(new Reference('event_dispatcher'));
38
    }
39
}
40