]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/RapsysUserExtension.php
Enable register captcha
[userbundle] / DependencyInjection / RapsysUserExtension.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys UserBundle 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\UserBundle\DependencyInjection;
13
14 use Rapsys\UserBundle\RapsysUserBundle;
15
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Extension\Extension;
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 class RapsysUserExtension 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 //Set bundle alias
36 $alias = RapsysUserBundle::getAlias();
37
38 //Detect when no user configuration is provided
39 if ($configs === [[]]) {
40 //Prepend default config
41 $container->prependExtensionConfig($alias, $config);
42 }
43
44 //Save configuration in parameters
45 $container->setParameter($alias, $config);
46
47 //Set rapsysuser.alias key
48 $container->setParameter($alias.'.alias', $alias);
49
50 //Set rapsysuser.version key
51 $container->setParameter($alias.'.version', RapsysUserBundle::getVersion());
52 }
53
54 /**
55 * {@inheritdoc}
56 *
57 * @xxx Required by kernel to load renamed alias configuration
58 */
59 public function getAlias(): string {
60 return RapsysUserBundle::getAlias();
61 }
62 }