Completed
Push — signal_search_issues ( 5556b2...f328ba )
by André
63:06 queued 07:22
created

AggregateFieldValueMapperPass::process()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 24
rs 8.9713
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\Elasticsearch;
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 (
28
            !$container->hasDefinition(
29
                'ezpublish.search.elasticsearch.content.field_value_mapper.aggregate'
30
            )
31
        ) {
32
            return;
33
        }
34
35
        $aggregateFieldValueMapperDefinition = $container->getDefinition(
36
            'ezpublish.search.elasticsearch.content.field_value_mapper.aggregate'
37
        );
38
39
        $taggedServiceIds = $container->findTaggedServiceIds(
40
            'ezpublish.search.elasticsearch.content.field_value_mapper'
41
        );
42
        foreach ($taggedServiceIds as $id => $attributes) {
43
            $aggregateFieldValueMapperDefinition->addMethodCall(
44
                'addMapper',
45
                [new Reference($id)]
46
            );
47
        }
48
    }
49
}
50