Completed
Push — master ( 007cba...a69311 )
by Christian
01:55 queued 11s
created

JMSHandlersPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 15
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 2
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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
namespace FOS\RestBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Alias;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * Checks if the JMS serializer is available to be able to use handlers.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 *
23
 * @internal
24
 */
25
final class JMSHandlersPass implements CompilerPassInterface
26
{
27
    public function process(ContainerBuilder $container): void
28
    {
29
        if ($container->has('jms_serializer.handler_registry')) {
30
            // the public alias prevents the handler registry definition from being removed
31
            $container->setAlias('fos_rest.serializer.jms_handler_registry', new Alias('jms_serializer.handler_registry', true));
32
33
            return;
34
        }
35
36
        $container->removeDefinition('fos_rest.serializer.handler_registry');
37
        $container->getParameterBag()->remove('jms_serializer.form_error_handler.class');
38
    }
39
}
40