ExclamationPass::process()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 5

Importance

Changes 4
Bugs 2 Features 1
Metric Value
c 4
b 2
f 1
dl 0
loc 27
ccs 18
cts 18
cp 1
rs 8.439
cc 5
eloc 16
nc 4
nop 1
crap 5
1
<?php
2
namespace Boekkooi\Bundle\TwigJackBundle\DependencyInjection\Compiler;
3
4
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Reference;
7
8
/**
9
 * @author Warnar Boekkooi <[email protected]>
10
 */
11
class ExclamationPass implements CompilerPassInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 5
    public function process(ContainerBuilder $container)
17
    {
18
        if (
19 5
            !$container->hasParameter('boekkooi.twig_jack.exclamation') ||
20 4
            !$container->getParameter('boekkooi.twig_jack.exclamation')
21 5
        ) {
22 2
            return;
23
        }
24
25
        # This will fail when templating is off
26
        # http://symfony.com/doc/current/book/templating.html#template-configuration
27 3
        $container->getDefinition('templating.name_parser')
28 3
            ->setClass('%templating.name_parser.class%');
29
30 3
        $container->getDefinition('templating.cache_warmer.template_paths')
31 3
            ->setClass('%templating.cache_warmer.template_paths.class%')
32 3
            ->addArgument(new Reference('kernel'));
33
34
        // Patch assetic service when availible
35 3
        if ($container->hasDefinition('assetic.twig_formula_loader.real')) {
36 1
            $container->getDefinition('assetic.twig_formula_loader.real')
37 1
                ->setClass('%assetic.twig_formula_loader.class%');
38 3
        } elseif ($container->hasDefinition('assetic.twig_formula_loader')) {
39 1
            $container->getDefinition('assetic.twig_formula_loader')
40 1
                ->setClass('%assetic.twig_formula_loader.class%');
41 1
        }
42 3
    }
43
}
44