Completed
Push — signal_search_issues ( 907e1e...5556b2 )
by André
26:47
created

AggregateFieldValueMapperPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 3
nop 1
dl 0
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
class AggregateFieldValueMapperPass implements CompilerPassInterface
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