1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\DoctrineORMAdminBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Sonata\AdminBundle\DependencyInjection\AbstractSonataAdminExtension; |
17
|
|
|
use Symfony\Component\Config\Definition\Processor; |
18
|
|
|
use Symfony\Component\Config\FileLocator; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
20
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @author Thomas Rabaix <[email protected]> |
24
|
|
|
* @author Michael Williams <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class SonataDoctrineORMAdminExtension extends AbstractSonataAdminExtension |
27
|
|
|
{ |
28
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
29
|
|
|
{ |
30
|
|
|
$configs = $this->fixTemplatesConfiguration($configs, $container); |
31
|
|
|
|
32
|
|
|
$configuration = new Configuration(); |
33
|
|
|
$processor = new Processor(); |
34
|
|
|
$config = $processor->processConfiguration($configuration, $configs); |
35
|
|
|
|
36
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
37
|
|
|
$loader->load('doctrine_orm.xml'); |
38
|
|
|
$loader->load('doctrine_orm_filter_types.xml'); |
39
|
|
|
|
40
|
|
|
$bundles = $container->getParameter('kernel.bundles'); |
41
|
|
|
|
42
|
|
|
if (isset($bundles['SimpleThingsEntityAuditBundle'])) { |
43
|
|
|
$loader->load('audit.xml'); |
44
|
|
|
|
45
|
|
|
$container->setParameter('sonata_doctrine_orm_admin.audit.force', $config['audit']['force']); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$loader->load('security.xml'); |
49
|
|
|
|
50
|
|
|
$container->setParameter('sonata_doctrine_orm_admin.entity_manager', $config['entity_manager']); |
51
|
|
|
|
52
|
|
|
$container->setParameter('sonata_doctrine_orm_admin.templates', $config['templates']); |
53
|
|
|
|
54
|
|
|
// define the templates |
55
|
|
|
$container->getDefinition('sonata.admin.builder.orm_list') |
56
|
|
|
->replaceArgument(1, $config['templates']['types']['list']); |
57
|
|
|
|
58
|
|
|
$container->getDefinition('sonata.admin.builder.orm_show') |
59
|
|
|
->replaceArgument(1, $config['templates']['types']['show']); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|