Completed
Push — master ( e9cd97...23520c )
by Rafał
23:17
created

ValidatorsCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 4
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Bridge Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\BridgeBundle\DependencyInjection\Compiler;
15
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
class ValidatorsCompilerPass implements CompilerPassInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('swp_bridge.http_push.validator_chain')) {
28
            return;
29
        }
30
31
        $definition = $container->getDefinition('swp_bridge.http_push.validator_chain');
32
33
        foreach ($container->findTaggedServiceIds('validator.http_push_validator') as $id => $tags) {
34
            foreach ($tags as $attributes) {
35
                $definition->addMethodCall(
36
                    'addValidator',
37
                    array(new Reference($id), $attributes['alias'])
38
                );
39
            }
40
        }
41
    }
42
}
43