1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Knp\RadBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
use Symfony\Component\Config\FileLocator; |
7
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* This is the class that loads and manages your bundle configuration |
13
|
|
|
* |
14
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
15
|
|
|
*/ |
16
|
|
|
class KnpRadExtension extends Extension |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritDoc} |
20
|
|
|
*/ |
21
|
|
|
public function load(array $configs, ContainerBuilder $container) |
22
|
|
|
{ |
23
|
|
|
$configuration = new Configuration(); |
24
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
25
|
|
|
|
26
|
|
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
27
|
|
|
|
28
|
|
|
$loader->load('bundle.xml'); |
29
|
|
|
$loader->load('controller_helper.xml'); |
30
|
|
|
|
31
|
|
|
foreach ($config['detect'] as $type => $isActivated) { |
32
|
|
|
$container->setParameter('knp_rad.detect.'.$type, $isActivated); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if ($config['domain_event']) { |
36
|
|
|
$loader->load('domain_event.xml'); |
37
|
|
|
} |
38
|
|
|
if ($config['mailer']['logger']) { |
39
|
|
|
$loader->load('mailer_logger.xml'); |
40
|
|
|
} |
41
|
|
|
if ($config['mailer']['message_factory']) { |
42
|
|
|
$loader->load('mailer_message_factory.xml'); |
43
|
|
|
} |
44
|
|
|
if ($config['listener']['view']) { |
45
|
|
|
$loader->load('view_listener.xml'); |
46
|
|
|
} |
47
|
|
|
if ($config['listener']['resource_resolver']) { |
48
|
|
|
$loader->load('resource_resolver_listener.xml'); |
49
|
|
|
} |
50
|
|
|
if ($config['listener']['orm_user']) { |
51
|
|
|
$loader->load('orm_user_listener.xml'); |
52
|
|
|
} |
53
|
|
|
if ($config['listener']['exception_rethrow']) { |
54
|
|
|
$loader->load('exception_rethrow_listener.xml'); |
55
|
|
|
} |
56
|
|
|
if ($config['routing_loader']) { |
57
|
|
|
$loader->load('routing_loader.xml'); |
58
|
|
|
} |
59
|
|
|
if ($config['form_manager']) { |
60
|
|
|
$loader->load('form_manager.xml'); |
61
|
|
|
} |
62
|
|
|
if ($config['security_voter']) { |
63
|
|
|
$loader->load('security_voter.xml'); |
64
|
|
|
} |
65
|
|
|
if ($config['datatable']) { |
66
|
|
|
$loader->load('datatable.xml'); |
67
|
|
|
} |
68
|
|
|
if ($config['alice']) { |
69
|
|
|
$loader->load('alice.xml'); |
70
|
|
|
} |
71
|
|
|
$container->setParameter('knp_rad.csrf_link.intention', $config['csrf_links']['intention']); |
72
|
|
|
if ($this->isConfigEnabled($container, $config['csrf_links'])) { |
73
|
|
|
$loader->load('link_attributes.xml'); |
74
|
|
|
} |
75
|
|
|
$container->setParameter('knp_rad.flashes.trans_catalog', $config['flashes']['trans_catalog']); |
76
|
|
|
if ($this->isConfigEnabled($container, $config['flashes'])) { |
77
|
|
|
$loader->load('flashes.xml'); |
78
|
|
|
} |
79
|
|
|
$container->setParameter('knp_rad.decision_manager.id', $config['security']['decision_manager']); |
80
|
|
|
|
81
|
|
|
$container->setAlias('knp_rad.resource.resolver.resource', 'knp_rad.resource.resolver.resource.aggregate'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getNamespace() |
85
|
|
|
{ |
86
|
|
|
return 'http://knplabs.com/schema/dic/rad'; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|