]> Raphaël G. Git Repositories - packbundle/blob - DependencyInjection/RapsysPackExtension.php
Skip short empty data
[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 /**
18 * This is the class that loads and manages your bundle configuration.
19 *
20 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
21 *
22 * {@inheritdoc}
23 */
24 class RapsysPackExtension extends Extension {
25 /**
26 * {@inheritdoc}
27 */
28 public function load(array $configs, ContainerBuilder $container): void {
29 //Load configuration
30 $configuration = $this->getConfiguration($configs, $container);
31
32 //Process the configuration to get merged config
33 $config = $this->processConfiguration($configuration, $configs);
34
35 //Detect when no user configuration is provided
36 if ($configs === [[]]) {
37 //Prepend default config
38 $container->prependExtensionConfig($this->getAlias(), $config);
39 }
40
41 //Save configuration in parameters
42 $container->setParameter($this->getAlias(), $config);
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 public function getAlias(): string {
49 return 'rapsys_pack';
50 }
51 }