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; |
|
|
|
|
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
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.