]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/RapsysUserExtension.php
Set mail as last field as it may be empty
[userbundle] / DependencyInjection / RapsysUserExtension.php
1 <?php
2
3 namespace Rapsys\UserBundle\DependencyInjection;
4
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Extension\Extension;
7
8 use Rapsys\UserBundle\RapsysUserBundle;
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 RapsysUserExtension extends Extension {
16 /**
17 * {@inheritdoc}
18 */
19 public function load(array $configs, ContainerBuilder $container) {
20 //Load configuration
21 $configuration = $this->getConfiguration($configs, $container);
22
23 //Process the configuration to get merged config
24 $config = $this->processConfiguration($configuration, $configs);
25
26 //Detect when no user configuration is provided
27 if ($configs === [[]]) {
28 //Prepend default config
29 $container->prependExtensionConfig(self::getAlias(), $config);
30 }
31
32 //Save configuration in parameters
33 $container->setParameter(self::getAlias(), $config);
34 }
35
36 /**
37 * {@inheritdoc}
38 */
39 public function getAlias(): string {
40 return RapsysUserBundle::getAlias();
41 }
42
43 /**
44 * The function that parses the array to flatten it into a one level depth array
45 *
46 * @param $array The config values array
47 * @param $path The current key path
48 * @param $depth The maxmium depth
49 * @param $sep The separator string
50 */
51 /*protected function flatten($array, $path = '', $depth = 10, $sep = '.') {
52 //Init res
53 $res = array();
54
55 //Pass through non hashed or empty array
56 if ($depth && is_array($array) && ($array === [] || array_keys($array) === range(0, count($array) - 1))) {
57 $res[$path] = $array;
58 //Flatten hashed array
59 } elseif ($depth && is_array($array)) {
60 foreach($array as $k => $v) {
61 $sub = $path ? $path.$sep.$k:$k;
62 $res += $this->flatten($v, $sub, $depth - 1, $sep);
63 }
64 //Pass scalar value directly
65 } else {
66 $res[$path] = $array;
67 }
68
69 //Return result
70 return $res;
71 }*/
72 }