Completed
Branch master (c0d8ef)
by Yaroslav
06:36
created

TwigBundlePass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
ccs 10
cts 10
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 3
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\DependencyInjection\Compiler;
12
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Yarhon\RouteGuardBundle\Twig\Extension\RoutingExtension;
16
use Yarhon\RouteGuardBundle\Twig\RoutingRuntime;
17
18
/**
19
 * @author Yaroslav Honcharuk <[email protected]>
20
 */
21
class TwigBundlePass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 4
    public function process(ContainerBuilder $container)
27
    {
28 4
        if (!$container->hasDefinition('twig')) {
29 1
            $container->removeDefinition(RoutingExtension::class);
30 1
            $container->removeDefinition(RoutingRuntime::class);
31
32 1
            return;
33
        }
34
35 3
        if (!$container->hasDefinition('twig.extension.routing')) {
36 1
            $definition = $container->getDefinition(RoutingExtension::class);
37 1
            $options = $definition->getArgument(0);
38 1
            $options['discover_routing_functions'] = false;
39 1
            $definition->replaceArgument(0, $options);
40
        }
41 3
    }
42
}
43