Passed
Push — master ( ef76e6...ea7306 )
by Alan
03:53
created

GraphQlMutationResolverPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
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
 * Injects GraphQL Mutation resolvers.
22
 *
23
 * @internal
24
 *
25
 * @author Raoul Clais <[email protected]>
26
 */
27
final class GraphQlMutationResolverPass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function process(ContainerBuilder $container)
33
    {
34
        $mutations = [];
35
        foreach ($container->findTaggedServiceIds('api_platform.graphql.mutation_resolver', true) as $serviceId => $tags) {
36
            foreach ($tags as $tag) {
37
                $mutations[$tag['id'] ?? $serviceId] = new Reference($serviceId);
38
            }
39
        }
40
41
        $container->getDefinition('api_platform.graphql.mutation_resolver_locator')->addArgument($mutations);
42
    }
43
}
44