Completed
Push — 2.2 ( 654e42...cc34af )
by Antoine
16s queued 10s
created

DataPersisterPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 2
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