]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/RapsysUserExtension.php
Add default title and group
[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 /**
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 RapsysUserExtension 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 getAlias() {
38 return 'rapsys_user';
39 }
40
41 /**
42 * The function that parses the array to flatten it into a one level depth array
43 *
44 * @param $array The config values array
45 * @param $path The current key path
46 * @param $depth The maxmium depth
47 * @param $sep The separator string
48 */
49 /*protected function flatten($array, $path = '', $depth = 10, $sep = '.') {
50 //Init res
51 $res = array();
52
53 //Pass through non hashed or empty array
54 if ($depth && is_array($array) && ($array === [] || array_keys($array) === range(0, count($array) - 1))) {
55 $res[$path] = $array;
56 //Flatten hashed array
57 } elseif ($depth && is_array($array)) {
58 foreach($array as $k => $v) {
59 $sub = $path ? $path.$sep.$k:$k;
60 $res += $this->flatten($v, $sub, $depth - 1, $sep);
61 }
62 //Pass scalar value directly
63 } else {
64 $res[$path] = $array;
65 }
66
67 //Return result
68 return $res;
69 }*/
70 }