TpgExtjsExtension   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 96.67%

Importance

Changes 8
Bugs 1 Features 3
Metric Value
wmc 8
c 8
b 1
f 3
lcom 0
cbo 6
dl 0
loc 46
ccs 29
cts 30
cp 0.9667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
C load() 0 35 7
A getConfiguration() 0 4 1
1
<?php
2
3
namespace Tpg\ExtjsBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Processor;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
use Symfony\Component\DependencyInjection\Loader;
10
11
/**
12
 * This is the class that loads and manages your bundle configuration
13
 *
14
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
15
 */
16
class TpgExtjsExtension extends Extension
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21 1
    public function load(array $configs, ContainerBuilder $container)
22
    {
23 1
        $processor = new Processor();
24 1
        $configuration = $this->getConfiguration($configs, $container);
25 1
        $config = $processor->processConfiguration($configuration, $configs);
26
27 1
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
28 1
        $loader->load('services.xml');
29
30 1
        $bundles = $container->getParameter('kernel.bundles');
31
        //Check Mongo or Doctrine bundle is loaded
32 1
        if (isset($bundles['DoctrineBundle'])) {
33 1
            $loader->load('orm.services.xml');
34 1
        }
35 1
        if (isset($bundles['DoctrineMongoDBBundle'])) {
36 1
            $loader->load('odm.services.xml');
37 1
        }
38
39 1
        $list = array();
40 1
        if (isset($config['remoting'])) {
41 1
            foreach ($config['remoting']['bundles'] as $bundleName) {
42 1
                if (isset($bundles[$bundleName])) {
43 1
                    $list[$bundleName] = $bundles[$bundleName];
44 1
                }
45 1
            }
46 1
        } else {
47
            $list = array();
48
        }
49
50 1
        $container->setParameter('tpg_extjs.remoting.bundles', $list);
51
52 1
        if (isset($config['entities'])) {
53 1
            $container->setParameter('tpg_extjs.entities', $config['entities']);
54 1
        }
55 1
    }
56
57 1
    public function getConfiguration(array $config, ContainerBuilder $container) {
58 1
        $bundles = $container->getParameter('kernel.bundles');
59 1
        return new Configuration(array_keys($bundles));
60
    }
61
}
62