Completed
Push — master ( abf7e9...c7e2cd )
by Kévin
16s
created

DataPersisterPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
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 data persisters.
22
 *
23
 * @internal
24
 *
25
 * @author Baptiste Meyer <[email protected]>
26
 */
27
final class DataPersisterPass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function process(ContainerBuilder $container)
33
    {
34
        $persisters = [];
35
        $services = $container->findTaggedServiceIds('api_platform.data_persister', true);
36
37
        foreach ($services as $serviceId => $tags) {
38
            $persisters[] = new Reference($serviceId);
39
        }
40
41
        $container->getDefinition('api_platform.data_persister')->addArgument($persisters);
42
    }
43
}
44