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\DoctrineMongoDBAdminBundle\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 SonataDoctrineMongoDBAdminExtension extends AbstractSonataAdminExtension |
27
|
|
|
{ |
28
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
29
|
|
|
{ |
30
|
|
|
$configs = $this->fixTemplatesConfiguration($configs, $container); |
31
|
|
|
|
32
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
33
|
|
|
$loader->load('doctrine_mongodb.xml'); |
34
|
|
|
$loader->load('doctrine_mongodb_filter_types.xml'); |
35
|
|
|
$loader->load('security.xml'); |
36
|
|
|
|
37
|
|
|
$configuration = new Configuration(); |
38
|
|
|
$processor = new Processor(); |
39
|
|
|
$config = $processor->processConfiguration($configuration, $configs); |
40
|
|
|
|
41
|
|
|
$container->setParameter('sonata_doctrine_mongodb_admin.templates', $config['templates']); |
42
|
|
|
|
43
|
|
|
// define the templates |
44
|
|
|
$container->getDefinition('sonata.admin.builder.doctrine_mongodb_list') |
45
|
|
|
->replaceArgument(1, $config['templates']['types']['list']); |
46
|
|
|
|
47
|
|
|
$container->getDefinition('sonata.admin.builder.doctrine_mongodb_show') |
48
|
|
|
->replaceArgument(1, $config['templates']['types']['show']); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|