Completed
Push — master ( d53149...bf867e )
by Antoine
20s queued 11s
created

MetadataAwareNameConverterPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 4 3
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 ApiPlatform\Core\Exception\RuntimeException;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
/**
21
 * Injects the metadata aware name converter if available.
22
 *
23
 * @internal
24
 *
25
 * @author Antoine Bluchet <[email protected]>
26
 */
27
final class MetadataAwareNameConverterPass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @throws RuntimeException
33
     */
34
    public function process(ContainerBuilder $container)
35
    {
36
        if (!$container->hasAlias('api_platform.name_converter') && $container->hasDefinition('serializer.name_converter.metadata_aware')) {
37
            $container->setAlias('api_platform.name_converter', 'serializer.name_converter.metadata_aware');
38
        }
39
    }
40
}
41