Completed
Push — master ( 2abc3b...5aa123 )
by Alexis
16:40
created

AlpixelMenuExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 7
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 15 2
1
<?php
2
3
namespace Alpixel\Bundle\MenuBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
use Symfony\Component\DependencyInjection\Loader;
9
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
10
11
/**
12
 * This is the class that loads and manages your bundle configuration.
13
 *
14
 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
15
 */
16
class AlpixelMenuExtension extends Extension
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function load(array $configs, ContainerBuilder $container)
22
    {
23
        if (!$container->hasParameter('locale')) {
24
            throw new UndefinedOptionsException('The locale parameter must be defined under parameters in your symfony configuration');
25
        }
26
27
        $configuration = new Configuration();
28
        $this->processConfiguration($configuration, $configs);
29
30
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31
        $loader->load('services.yml');
32
33
        $menuBuilder = $container->getDefinition('alpixel_menu.builder');
34
        $menuBuilder->addMethodCall('setDefaultLocale', [$container->getParameter('locale')] );
35
    }
36
}
37