Completed
Push — refonte ( 994918...f7c861 )
by Arnaud
02:21
created

LAGAdminExtension::load()   B

Complexity

Conditions 8
Paths 24

Size

Total Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 8.0035
c 0
b 0
f 0
cc 8
nc 24
nop 2
1
<?php
2
3
namespace LAG\AdminBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Loader;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
10
/**
11
 * Load AdminBundle configuration into the container.
12
 */
13
class LAGAdminExtension extends Extension
14
{
15
    /**
16
     * Load the configuration into the container.
17
     *
18
     * @param array $configs
19
     * @param ContainerBuilder $builder
20
     */
21
    public function load(array $configs, ContainerBuilder $builder)
22
    {
23
        $configuration = new Configuration();
24
        $config = $this->processConfiguration($configuration, $configs);
25
26
        $loader = new Loader\YamlFileLoader($builder, new FileLocator(__DIR__.'/../Resources/config'));
27
        $loader->load('services.yml');
28
29
        if ('dev' === $builder->getParameter('kernel.environment')) {
30
            $loader->load('services_dev.yml');
31
        }
32
        $applicationConfig = [];
33
        $adminsConfig = [];
34
        $menusConfig = [];
35
        $enableExtraConfig = true;
36
        $translationPattern = null;
0 ignored issues
show
Unused Code introduced by
$translationPattern is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
37
        
38
        if (key_exists('application', $config)) {
39
            if (key_exists('enable_extra_configuration', $config['application'])) {
40
                $enableExtraConfig = $config['application']['enable_extra_configuration'];
41
            }
42
            $applicationConfig = $config['application'];
43
        }
44
45
        if (key_exists('admins', $config)) {
46
            $adminsConfig = $config['admins'];
47
        }
48
49
        if (key_exists('menus', $config)) {
50
            $menusConfig = $config['menus'];
51
52
            foreach ($menusConfig as $name => $menu) {
53
                if (null === $menu) {
54
                    $menusConfig[$name] = [];
55
                }
56
            }
57
        }
58
        $builder->setParameter('lag.admin.enable_extra_configuration', $enableExtraConfig);
59
        $builder->setParameter('lag.admin.application_configuration', $applicationConfig);
60
        $builder->setParameter('lag.admins', $adminsConfig);
61
        $builder->setParameter('lag.menus', $menusConfig);
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getAlias()
68
    {
69
        return 'lag_admin';
70
    }
71
}
72