1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace FSi\Bundle\AdminBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use FSi\Bundle\AdminBundle\Admin\Element; |
15
|
|
|
use Symfony\Component\Config\FileLocator; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
18
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
19
|
|
|
|
20
|
|
|
class FSIAdminExtension extends Extension |
21
|
|
|
{ |
22
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
23
|
|
|
{ |
24
|
|
|
$configuration = new Configuration(); |
25
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
26
|
|
|
|
27
|
|
|
$container->setParameter('admin.locales', $config['locales']); |
28
|
|
|
$container->setParameter('admin.default_locale', $config['default_locale']); |
29
|
|
|
$container->setParameter('admin.menu_config_path', $config['menu_config_path']); |
30
|
|
|
$container->setParameter('admin.elements.dirs', $config['annotations']['dirs']); |
31
|
|
|
$container->registerForAutoconfiguration(Element::class)->addTag('admin.element'); |
32
|
|
|
|
33
|
|
|
$this->setTemplateParameters($container, $config['templates']); |
34
|
|
|
|
35
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
36
|
|
|
$loader->load('services.xml'); |
37
|
|
|
$loader->load('datagrid.xml'); |
38
|
|
|
$loader->load('menu.xml'); |
39
|
|
|
$loader->load('knp-menu.xml'); |
40
|
|
|
|
41
|
|
|
$loader->load('locale_listener.xml'); |
42
|
|
|
|
43
|
|
|
$loader->load('context/list.xml'); |
44
|
|
|
$loader->load('context/form.xml'); |
45
|
|
|
$loader->load('context/batch.xml'); |
46
|
|
|
$loader->load('context/display.xml'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
protected function setTemplateParameters(ContainerBuilder $container, array $config = []): void |
50
|
|
|
{ |
51
|
|
|
foreach ($config as $key => $value) { |
52
|
|
|
$container->setParameter(sprintf('admin.templates.%s', $key), $value); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|