ValidatorsCompilerPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 1
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
15
namespace SWP\Bundle\BridgeBundle\DependencyInjection\Compiler;
16
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
class ValidatorsCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        if (!$container->hasDefinition('swp_bridge.http_push.validator_chain')) {
29
            return;
30
        }
31
32
        $definition = $container->getDefinition('swp_bridge.http_push.validator_chain');
33
34
        foreach ($container->findTaggedServiceIds('validator.http_push_validator') as $id => $tags) {
35
            foreach ($tags as $attributes) {
36
                $definition->addMethodCall(
37
                    'addValidator',
38
                    array(new Reference($id), $attributes['alias'])
39
                );
40
            }
41
        }
42
    }
43
}
44