FieldFilterCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 32
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 27 4
1
<?php
2
3
4
namespace Mdiyakov\DoctrineSolrBundle\DependencyInjection;
5
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class FieldFilterCompilerPass implements CompilerPassInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function process(ContainerBuilder $container)
17
    {
18
        if (!$container->has('mdiyakov_doctrine_solr.filter.validator')) {
19
            return;
20
        }
21
22
        $definition = $container->findDefinition('mdiyakov_doctrine_solr.filter.validator');
23
        $taggedFieldFilterServices = $container->findTaggedServiceIds(
24
            'doctrine_solr.field_filter'
25
        );
26
27
        $taggedFilterServices = $container->findTaggedServiceIds(
28
            'doctrine_solr.service_filter'
29
        );
30
31
32
        foreach ($taggedFieldFilterServices as $id => $tags) {
33
            $definition->addMethodCall(
34
                'addFieldFilter',
35
                [new Reference($id)]
36
            );
37
        }
38
39
        foreach ($taggedFilterServices as $id => $tags) {
40
            $definition->addMethodCall(
41
                'addServiceEntityFilter',
42
                [$id, new Reference($id)]
43
            );
44
        }
45
    }
46
}