Completed
Push — sf4-again ( 823c77...de3216 )
by Asmir
02:41 queued 31s
created

GoetasTwitalExtension   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 93.1%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 7
dl 0
loc 44
ccs 27
cts 29
cp 0.931
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C load() 0 38 8
1
<?php
2
3
namespace Goetas\TwitalBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\Definition;
6
7
use Goetas\TwitalBundle\Assetic\DirectoryResourceDefinition;
8
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\Config\FileLocator;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
use Symfony\Component\DependencyInjection\Loader;
13
use Symfony\Component\DependencyInjection\Reference;
14
15
/**
16
 *
17
 * @author Asmir Mustafic <[email protected]>
18
 *
19
 */
20
class GoetasTwitalExtension extends Extension
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25 6
    public function load(array $configs, ContainerBuilder $container)
26
    {
27 6
        $configuration = new Configuration();
28 6
        $config = $this->processConfiguration($configuration, $configs);
29
30 6
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
31 6
        $loader->load('twital.xml');
32
33
34 6
        $loaderDefinition = $container->getDefinition("twital.loader");
35 6
        foreach ($config["source_adapters"] as $id => $regs) {
36 6
            foreach ($regs["pattern"] as $reg) {
37 6
                $loaderDefinition->addMethodCall('addSourceAdapter', array($reg, new Reference($id)));
38 6
            }
39 6
        }
40
41 6
        $bundles = $container->getParameter("kernel.bundles");
42 6
        if (isset($bundles["AsseticBundle"])) {
43 1
            $loader->load('assetic.xml');
44 1
        }
45
46 6
        if (isset($bundles["JMSTranslationBundle"])) {
47 1
            $loader->load('jms-translation-bundle.xml');
48 1
        }
49
50 6
        if (!empty($config["full_twig_compatibility"])) {
51 1
            $twitalDefinitioin = $container->getDefinition("twital");
52 1
            $twitalDefinitioin->addMethodCall('addExtension', array(new Reference('twital.extension.full_twig_compatibility')));
53 1
        }
54
55 6
        if (!class_exists('Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface')) {
56 6
            $container->removeDefinition('twital.cache_warmer');
57 6
        }
58
59 6
        if (!class_exists('Symfony\Bundle\TwigBundle\TwigEngine')) {
60
            $container->removeDefinition('templating.engine.twital');
61
        }
62 6
    }
63
}
64