3 namespace Rapsys\UserBundle\DependencyInjection
;
5 use Symfony\Component\DependencyInjection\ContainerBuilder
;
6 use Symfony\Component\DependencyInjection\Extension\Extension
;
8 use Rapsys\UserBundle\RapsysUserBundle
;
11 * This is the class that loads and manages your bundle configuration.
13 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
15 class RapsysUserExtension
extends Extension
{
19 public function load(array $configs, ContainerBuilder
$container) {
21 $configuration = $this->getConfiguration($configs, $container);
23 //Process the configuration to get merged config
24 $config = $this->processConfiguration($configuration, $configs);
26 //Detect when no user configuration is provided
27 if ($configs === [[]]) {
28 //Prepend default config
29 $container->prependExtensionConfig(self
::getAlias(), $config);
32 //Save configuration in parameters
33 $container->setParameter(self
::getAlias(), $config);
39 public function getAlias(): string {
40 return RapsysUserBundle
::getAlias();
44 * The function that parses the array to flatten it into a one level depth array
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
51 /*protected function flatten($array, $path = '', $depth = 10, $sep = '.') {
55 //Pass through non hashed or empty array
56 if ($depth && is_array($array) && ($array === [] || array_keys($array) === range(0, count($array) - 1))) {
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);
64 //Pass scalar value directly