]> Raphaël G. Git Repositories - packbundle/blob - DependencyInjection/RapsysPackExtension.php
Add facebook subscriber service
[packbundle] / DependencyInjection / RapsysPackExtension.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys PackBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
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 Rapsys\PackBundle\DependencyInjection;
13
14 use Symfony\Component\DependencyInjection\ContainerBuilder;
15 use Symfony\Component\DependencyInjection\Extension\Extension;
16
17 use Rapsys\PackBundle\RapsysPackBundle;
18
19 /**
20 * This is the class that loads and manages your bundle configuration.
21 *
22 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
23 *
24 * {@inheritdoc}
25 */
26 class RapsysPackExtension extends Extension {
27 /**
28 * {@inheritdoc}
29 */
30 public function load(array $configs, ContainerBuilder $container): void {
31 //Load configuration
32 $configuration = $this->getConfiguration($configs, $container);
33
34 //Process the configuration to get merged config
35 $config = $this->processConfiguration($configuration, $configs);
36
37 //Detect when no user configuration is provided
38 if ($configs === [[]]) {
39 //Prepend default config
40 $container->prependExtensionConfig(self::getAlias(), $config);
41 }
42
43 //Save configuration in parameters
44 $container->setParameter(self::getAlias(), $config);
45
46 //Set rapsys_pack.public.path key
47 $container->setParameter(self::getAlias().'.public.path', $config['public']['path']);
48
49 //Set rapsys_pack.public.url key
50 $container->setParameter(self::getAlias().'.public.url', $config['public']['url']);
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function getAlias(): string {
57 return RapsysPackBundle::getAlias();
58 }
59 }