1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Config\FileLocator; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
10
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
11
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
12
|
|
|
|
13
|
|
|
class LAGAdminExtension extends Extension implements PrependExtensionInterface |
14
|
|
|
{ |
15
|
3 |
|
public function load(array $configs, ContainerBuilder $container): void |
16
|
|
|
{ |
17
|
3 |
|
$configuration = new Configuration(); |
18
|
3 |
|
$config = $this->processConfiguration($configuration, $configs); |
19
|
|
|
|
20
|
3 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
21
|
3 |
|
$loader->load('services.yaml'); |
22
|
|
|
|
23
|
3 |
|
if ($container->getParameter('kernel.environment') === 'dev') { |
24
|
2 |
|
$loader->load('services_dev.yaml'); |
25
|
|
|
} |
26
|
|
|
|
27
|
3 |
|
if ($container->getParameter('kernel.environment') === 'prod') { |
28
|
|
|
if (!\array_key_exists('application', $config)) { |
29
|
|
|
$config['resources_path'] = '%kernel.project_dir%/config/admin/resources'; |
30
|
|
|
} |
31
|
|
|
} |
32
|
3 |
|
if (!\array_key_exists('menus', $config)) { |
33
|
3 |
|
$config['menus'] = []; |
34
|
|
|
} |
35
|
3 |
|
$container->setParameter('lag_admin.application.configuration', $config); |
36
|
3 |
|
$container->setParameter('lag_admin.menu.menus', $config['menus']); |
37
|
3 |
|
$container->setParameter('lag_admin.resources.path', $config['resources_path']); |
38
|
3 |
|
$container->setParameter('lag_admin.media.bundle_enabled', \array_key_exists('JKMediaBundle', $container->getParameter('kernel.bundles'))); |
|
|
|
|
39
|
3 |
|
$container->setParameter('lag_admin.fields.mapping', $config['fields_mapping']); |
40
|
3 |
|
} |
41
|
|
|
|
42
|
1 |
|
public function getAlias(): string |
43
|
|
|
{ |
44
|
1 |
|
return 'lag_admin'; |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
public function prepend(ContainerBuilder $container): void |
48
|
|
|
{ |
49
|
1 |
|
$container->prependExtensionConfig('knp_menu', [ |
50
|
|
|
'twig' => [ |
51
|
1 |
|
'template' => '@LAGAdmin/menu/menu-base.html.twig', |
52
|
|
|
], |
53
|
|
|
]); |
54
|
1 |
|
$container->prependExtensionConfig('twig', [ |
55
|
1 |
|
'form_themes' => ['@LAGAdmin/form/fields.html.twig'], |
56
|
|
|
]); |
57
|
1 |
|
} |
58
|
|
|
} |
59
|
|
|
|