Completed
Pull Request — master (#3346)
by Tomas
07:45
created

ValidationGroupsGeneratorFilterPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ApiPlatform\Core\Bridge\Symfony\Bundle\DependencyInjection\Compiler;
15
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
/**
21
 * Registers validation groups generators.
22
 *
23
 * @internal
24
 *
25
 * @author Tomas Norkūnas <[email protected]>
26
 */
27
final class ValidationGroupsGeneratorFilterPass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function process(ContainerBuilder $container)
33
    {
34
        $generators = [];
35
36
        foreach ($container->findTaggedServiceIds('api_platform.validation_groups_generator', true) as $serviceId => $tags) {
37
            $generators[$serviceId] = new Reference($serviceId);
38
        }
39
40
        $container->getDefinition('api_platform.validator.groups_generator_locator')->setArgument(0, $generators);
41
    }
42
}
43