This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLiipVieExtension.php
62 lines (54 loc) · 2.25 KB
/
LiipVieExtension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Liip\VieBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class LiipVieExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
if (!empty($config['phpcr'])) {
$loader->load('phpcr.xml');
if (is_string($config['phpcr'])) {
$phpcr = $container->getDefinition('liip_vie.phpcr.controller');
$phpcr->replaceArgument(4, $config['phpcr']);
}
}
if (!empty($config['phpcr_odm'])) {
$loader->load('phpcr_odm.xml');
if (is_string($config['phpcr_odm'])) {
$phpcr_odm = $container->getDefinition('liip_vie.phpcr_odm.controller');
$phpcr_odm->replaceArgument(4, $config['phpcr_odm']);
}
}
if (!empty($config['orm'])) {
$loader->load('orm.xml');
if (is_string($config['orm'])) {
$phpcr = $container->getDefinition('liip_vie.orm.controller');
$phpcr->replaceArgument(4, $config['orm']);
}
}
$container->setParameter($this->getAlias().'.map', $config['map']);
$container->setParameter($this->getAlias().'.use_coffee', $config['use_coffee']);
$container->setParameter($this->getAlias().'.base_path', $config['base_path']);
$container->setParameter($this->getAlias().'.cms_path', $config['cms_path']);
if (!empty($config['filter'])) {
$loader->load('filter.xml');
}
$loader->load('services.xml');
}
}