Completed
Branch master (0104dc)
by Warnar
15:12 queued 03:35
created

ExclamationPass::process()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 4

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 8.6845
cc 4
eloc 13
nc 3
nop 1
crap 4
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 4
    public function process(ContainerBuilder $container)
17
    {
18
        if (
19 4
            !$container->hasParameter('boekkooi.twig_jack.exclamation') ||
20 3
            !$container->getParameter('boekkooi.twig_jack.exclamation')
21 4
        ) {
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 2
        $container->getDefinition('templating.name_parser')
28 2
            ->setClass('%templating.name_parser.class%');
29
30 2
        $container->getDefinition('templating.cache_warmer.template_paths')
31 2
            ->setClass('%templating.cache_warmer.template_paths.class%')
32 2
            ->addArgument(new Reference('kernel'));
33
34
        // Patch assetic service when availible
35 2
        if ($container->hasDefinition('assetic.twig_formula_loader')) {
36 1
            $container->getDefinition('assetic.twig_formula_loader')
37 1
                ->setClass('%assetic.twig_formula_loader.class%');
38 1
        }
39 2
    }
40
}
41