Completed
Push — master ( 044f4e...849b11 )
by Lukas Kahwe
04:34
created

TwigExceptionPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.25

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 8
cp 0.75
rs 9.2
cc 4
eloc 5
nc 4
nop 1
crap 4.25
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\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Remove the 'twig.exception_listener' service if 'fos_rest.exception_listener' is activated.
19
 *
20
 * @internal
21
 */
22
final class TwigExceptionPass implements CompilerPassInterface
23
{
24 6
    public function process(ContainerBuilder $container)
25
    {
26 6
        if ($container->has('fos_rest.exception_listener') && $container->has('twig.exception_listener')) {
27
            $container->removeDefinition('twig.exception_listener');
28
        }
29
30 6
        if (!$container->has('templating.engine.twig')) {
31 5
            $container->removeDefinition('fos_rest.exception.twig_controller');
32 5
        }
33 6
    }
34
}
35