Completed
Push — master ( fdbeef...265a2d )
by jerome
25:01 queued 21:35
created

DPCoreExtension::addContainerParameters()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
1
<?php
2
3
/**
4
 * This file is part of Dedipanel project
5
 *
6
 * (c) 2010-2015 Dedipanel <http://www.dedicated-panel.net>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DP\Core\CoreBundle\DependencyInjection;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17
use Symfony\Component\DependencyInjection\Loader;
18
19
/**
20
 * This is the class that loads and manages your bundle configuration
21
 *
22
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
23
 */
24
class DPCoreExtension extends Extension
25
{
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function load(array $configs, ContainerBuilder $container)
30
    {
31
        $configuration = new Configuration();
32
        $config = $this->processConfiguration($configuration, $configs);
33
34
        $this->addContainerParameters($configs, $container);
35
36
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
37
        $loader->load('services.yml');
38
    }
39
40
    private function addContainerParameters(array $configs, ContainerBuilder $container)
41
    {
42
        $vals = [
43
            'debug' => false,
44
            'version' => '',
45
        ];
46
47
        foreach ($vals AS $key => $val) {
48
            $val = (isset($configs[0][$key]) ? $configs[0][$key] : $val);
49
50
            $container->setParameter('dedipanel.' . $key, $val);
51
        }
52
    }
53
}
54