]> Raphaƫl G. Git Repositories - packbundle/blob - DependencyInjection/RapsysPackExtension.php
Move the configuration in rapsys_pack key
[packbundle] / DependencyInjection / RapsysPackExtension.php
1 <?php
2
3 namespace Rapsys\PackBundle\DependencyInjection;
4
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Extension\Extension;
7
8 /**
9 * This is the class that loads and manages your bundle configuration.
10 *
11 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
12 */
13 class RapsysPackExtension extends Extension {
14 /**
15 * {@inheritdoc}
16 */
17 public function load(array $configs, ContainerBuilder $container) {
18 //Load configuration
19 $configuration = $this->getConfiguration($configs, $container);
20
21 //Process the configuration to get merged config
22 $config = $this->processConfiguration($configuration, $configs);
23
24 //Detect when no user configuration is provided
25 if ($configs === [[]]) {
26 //Prepend default config
27 $container->prependExtensionConfig($this->getAlias(), $config);
28 }
29
30 //Save configuration in parameters
31 $container->setParameter($this->getAlias(), $config);
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function getConfiguration(array $configs, ContainerBuilder $container) {
38 //Get configuration instance with resolved public path
39 return new Configuration($container->getParameter('kernel.project_dir').'/public/');
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function getAlias() {
46 return 'rapsys_pack';
47 }
48 }