]> Raphaƫl G. Git Repositories - airbundle/blob - DependencyInjection/RapsysAirExtension.php
Revert for now
[airbundle] / DependencyInjection / RapsysAirExtension.php
1 <?php
2
3 namespace Rapsys\AirBundle\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
10 /**
11 * This is the class that loads and manages your bundle configuration.
12 *
13 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
14 */
15 class RapsysAirExtension extends Extension {
16 /**
17 * {@inheritdoc}
18 */
19 public function load(array $configs, ContainerBuilder $container) {
20 $loader = new Loader\YamlFileLoader($container, new FileLocator('config/packages'));
21 $loader->load($this->getAlias().'.yaml');
22
23 $configuration = new Configuration();
24 $config = $this->processConfiguration($configuration, $configs);
25
26 //Set default config in parameter
27 if (!$container->hasParameter($alias = $this->getAlias())) {
28 $container->setParameter($alias, $config[$alias]);
29 } else {
30 $config[$alias] = $container->getParameter($alias);
31 }
32
33 //Transform the one level tree in flat parameters
34 foreach($config[$alias] as $k => $v) {
35 //Set is as parameters
36 $container->setParameter($alias.'.'.$k, $v);
37 }
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 public function getAlias() {
44 return 'rapsys_air';
45 }
46 }