|
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\Extension\PrependExtensionInterface; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Load AdminBundle configuration into the container. |
|
13
|
|
|
*/ |
|
14
|
|
|
class LAGAdminExtension extends Extension implements PrependExtensionInterface |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Load the configuration into the container. |
|
18
|
6 |
|
*/ |
|
19
|
|
|
public function load(array $configs, ContainerBuilder $builder) |
|
20
|
6 |
|
{ |
|
21
|
6 |
|
$configuration = new Configuration(); |
|
22
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
23
|
6 |
|
|
|
24
|
6 |
|
$loader = new Loader\YamlFileLoader($builder, new FileLocator(__DIR__.'/../Resources/config')); |
|
25
|
|
|
$loader->load('services.yaml'); |
|
26
|
6 |
|
|
|
27
|
|
|
if ('dev' === $builder->getParameter('kernel.environment')) { |
|
28
|
|
|
$loader->load('services_dev.yaml'); |
|
29
|
6 |
|
} |
|
30
|
6 |
|
$adminsConfig = []; |
|
31
|
6 |
|
$enableExtraConfig = true; |
|
32
|
|
|
|
|
33
|
6 |
|
if (!key_exists('application', $config)) { |
|
34
|
|
|
$config['application'] = [ |
|
35
|
|
|
'enable_menus' => true, |
|
36
|
|
|
'resources_path' => null, |
|
37
|
|
|
]; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
6 |
|
if (key_exists('enable_extra_configuration', $config['application'])) { |
|
41
|
6 |
|
$enableExtraConfig = $config['application']['enable_extra_configuration']; |
|
42
|
|
|
} |
|
43
|
|
|
$applicationConfig = $config['application']; |
|
44
|
6 |
|
|
|
45
|
|
|
if (key_exists('admins', $config)) { |
|
46
|
|
|
$adminsConfig = $config['admins']; |
|
47
|
6 |
|
} |
|
48
|
6 |
|
|
|
49
|
6 |
|
if (!key_exists('menus', $config)) { |
|
50
|
6 |
|
$config['menus'] = []; |
|
51
|
6 |
|
} |
|
52
|
|
|
$builder->setParameter('lag.admin.enable_extra_configuration', $enableExtraConfig); |
|
53
|
|
|
$builder->setParameter('lag.admin.application_configuration', $applicationConfig); |
|
54
|
|
|
$builder->setParameter('lag.admins', $adminsConfig); |
|
55
|
|
|
$builder->setParameter('lag.menus', $config['menus']); |
|
56
|
2 |
|
$builder->setParameter('lag.enable_menus', $config['application']['enable_menus']); |
|
57
|
|
|
$builder->setParameter('lag.admin.resources_path', $config['application']['resources_path']); |
|
58
|
2 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getAlias() |
|
64
|
|
|
{ |
|
65
|
|
|
return 'lag_admin'; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function prepend(ContainerBuilder $container) |
|
69
|
|
|
{ |
|
70
|
|
|
$container->prependExtensionConfig('knp_menu', [ |
|
71
|
|
|
'twig' => [ |
|
72
|
|
|
'template' => '@LAGAdmin/Menu/menu-base.html.twig', |
|
73
|
|
|
], |
|
74
|
|
|
]); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|