|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* This is the class that loads and manages your bundle configuration. |
|
13
|
|
|
* |
|
14
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
15
|
|
|
*/ |
|
16
|
|
|
class LAGAdminExtension extends Extension |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
22
|
|
|
{ |
|
23
|
|
|
$configuration = new Configuration(); |
|
24
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
25
|
|
|
|
|
26
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
27
|
|
|
$loader->load('services.yml'); |
|
28
|
|
|
|
|
29
|
|
|
if (!array_key_exists('application', $config)) { |
|
30
|
|
|
throw new InvalidConfigurationException('Your section "application" is not found for AdminBundle configuration'); |
|
31
|
|
|
} |
|
32
|
|
|
if (!array_key_exists('admins', $config)) { |
|
33
|
|
|
throw new InvalidConfigurationException('Your section "admins" is not found for AdminBundle configuration'); |
|
34
|
|
|
} |
|
35
|
|
|
if (!array_key_exists('enable_extra_configuration', $config['application'])) { |
|
36
|
|
|
$config['application']['enable_extra_configuration'] = true; |
|
37
|
|
|
} |
|
38
|
|
|
$container->setParameter('lag.admins', $config['admins']); |
|
39
|
|
|
$container->setParameter('lag.menus', $config['menus']); |
|
40
|
|
|
$container->setParameter('lag.admin.application_configuration', $config['application']); |
|
41
|
|
|
$container->setParameter('lag.enable_extra_configuration', $config['application']['enable_extra_configuration']); |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getAlias() |
|
47
|
|
|
{ |
|
48
|
|
|
return 'lag_admin'; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|