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

AggregateFieldValueMapperPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 3
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