Completed
Push — master ( 488d96...39c422 )
by Alex
05:30
created

OrbitaleCmsExtension::load()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 3
eloc 16
nc 4
nop 2
1
<?php
2
3
/*
4
* This file is part of the OrbitaleCmsBundle package.
5
*
6
* (c) Alexandre Rock Ancelet <[email protected]>
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 Orbitale\Bundle\CmsBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
use Symfony\Component\HttpKernel\Kernel;
19
20
/**
21
 * This is the class that loads and manages your bundle configuration.
22
 *
23
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
24
 */
25
class OrbitaleCmsExtension extends Extension
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function load(array $configs, ContainerBuilder $container)
31
    {
32
        $configuration = new Configuration();
33
        $config        = $this->processConfiguration($configuration, $configs);
34
35
        foreach ($config['layouts'] as $name => $layout) {
36
            $config['layouts'][$name] = array_merge([
37
                'name'       => $name,
38
                'assets_css' => [],
39
                'assets_js'  => [],
40
                'host'       => '',
41
                'pattern'    => '',
42
            ], $layout);
43
            ksort($config['layouts'][$name]);
44
        }
45
46
        foreach ($config as $key => $value) {
47
            $container->setParameter('orbitale_cms.'.$key, $value);
48
        }
49
50
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
51
        $loader->load('services.yml');
52
    }
53
}
54