Completed
Pull Request — master (#1376)
by Guilh
08:48 queued 06:22
created

TwigExceptionPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 4
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 8
    public function process(ContainerBuilder $container)
25
    {
26 8
        if ($container->has('fos_rest.exception_listener') && $container->has('twig.exception_listener')) {
27 2
            $container->removeDefinition('twig.exception_listener');
28 2
        }
29
30 8
        if (!$container->has('templating.engine.twig')) {
31 3
            $container->removeDefinition('fos_rest.exception.twig_controller');
32 3
        }
33 8
    }
34
}
35