1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the OrbitaleCmsBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Alexandre Rock Ancelet <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Orbitale\Bundle\CmsBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* This is the class that loads and manages your bundle configuration. |
22
|
|
|
* |
23
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
24
|
|
|
*/ |
25
|
|
|
class OrbitaleCmsExtension extends Extension |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
public function load(array $configs, ContainerBuilder $container) |
31
|
|
|
{ |
32
|
|
|
$configuration = new Configuration(); |
33
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
34
|
|
|
|
35
|
|
|
foreach ($config['layouts'] as $name => $layout) { |
36
|
|
|
$config['layouts'][$name] = array_merge([ |
37
|
|
|
'name' => $name, |
38
|
|
|
'assets_css' => [], |
39
|
|
|
'assets_js' => [], |
40
|
|
|
'host' => '', |
41
|
|
|
'pattern' => '', |
42
|
|
|
], $layout); |
43
|
|
|
ksort($config['layouts'][$name]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
foreach ($config as $key => $value) { |
47
|
|
|
$container->setParameter('orbitale_cms.' . $key, $value); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
51
|
|
|
$loader->load('services.yml'); |
52
|
|
|
if ($this->isSymfony3()) { |
53
|
|
|
$loader->load('services_v3.yml'); |
54
|
|
|
} else { |
55
|
|
|
$loader->load('services_v2.yml'); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
|
|
protected function isSymfony3() |
63
|
|
|
{ |
64
|
|
|
return 3 === Kernel::MAJOR_VERSION; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|