Completed
Push — master ( 3a8823...81c6e7 )
by Piotr
02:46
created

FSIAdminExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 25 1
A setTemplateParameters() 0 6 2
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\DependencyInjection;
11
12
use Symfony\Component\Config\FileLocator;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
15
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16
17
/**
18
 * @author Norbert Orzechowicz <[email protected]>
19
 */
20
class FSIAdminExtension extends Extension
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function load(array $configs, ContainerBuilder $container)
26
    {
27
        $configuration = new Configuration();
28
        $config = $this->processConfiguration($configuration, $configs);
29
30
        $container->setParameter('admin.locales', $config['locales']);
31
        $container->setParameter('admin.default_locale', $config['default_locale']);
32
        $container->setParameter('admin.menu_config_path', $config['menu_config_path']);
33
        $container->setParameter('admin.elements.dirs', $config['annotations']['dirs']);
34
35
        $this->setTemplateParameters($container, $config['templates']);
36
37
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
38
        $loader->load('services.xml');
39
        $loader->load('datagrid.xml');
40
        $loader->load('menu.xml');
41
        $loader->load('knp-menu.xml');
42
43
        $loader->load('locale_listener.xml');
44
45
        $loader->load('context/list.xml');
46
        $loader->load('context/form.xml');
47
        $loader->load('context/batch.xml');
48
        $loader->load('context/display.xml');
49
    }
50
51
    /**
52
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
53
     * @param array $config
54
     */
55
    protected function setTemplateParameters(ContainerBuilder $container, $config = array())
56
    {
57
        foreach ($config as $key => $value) {
58
            $container->setParameter(sprintf('admin.templates.%s', $key), $value);
59
        }
60
    }
61
}
62