Completed
Push — EZP-25088-common-field-value-m... ( 21b8e9 )
by
unknown
24:48
created

AggregateFieldValueMapperPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 11

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 3
nop 1
dl 20
loc 20
rs 9.4285
1
<?php
2
3
/**
4
 * File containing the AggregateFieldValueMapperPass class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 *
9
 * @version //autogentag//
10
 */
11
namespace eZ\Publish\Core\Base\Container\Compiler\Search;
12
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Reference;
16
17
/**
18
 * This compiler pass will register Elasticsearch Search Engine field value mappers.
19
 */
20 View Code Duplication
class AggregateFieldValueMapperPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('ezpublish.search.common.field_value_mapper.aggregate')) {
28
            return;
29
        }
30
31
        $aggregateFieldValueMapperDefinition = $container->getDefinition(
32
            'ezpublish.search.common.field_value_mapper.aggregate'
33
        );
34
35
        $taggedServiceIds = $container->findTaggedServiceIds(
36
            'ezpublish.search.common.field_value_mapper'
37
        );
38
        foreach ($taggedServiceIds as $id => $attributes) {
39
            $aggregateFieldValueMapperDefinition->addMethodCall(
40
                'addMapper',
41
                [new Reference($id)]
42
            );
43
        }
44
    }
45
}
46