3 namespace Rapsys\UserBundle\DependencyInjection
; 
   5 use Symfony\Component\DependencyInjection\ContainerBuilder
; 
   6 use Symfony\Component\Config\FileLocator
; 
   7 use Symfony\Component\HttpKernel\DependencyInjection\Extension
; 
   8 use Symfony\Component\DependencyInjection\Loader
; 
  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                 $loader = new Loader\
YamlFileLoader($container, new FileLocator('config/packages')); 
  22                 $loader->load($this->getAlias().'.yaml'); 
  25                 $configuration = $this->getConfiguration($configs, $container); 
  26                 $config = $this->processConfiguration($configuration, $configs); 
  28                 //Set default config in parameter 
  29                 if (!$container->hasParameter($alias = $this->getAlias())) { 
  30                         $container->setParameter($alias, $config[$alias]); 
  32                         $config[$alias] = $container->getParameter($alias); 
  35                 //Transform the two level tree in flat parameters 
  36                 foreach($config[$alias] as $k => $v) { 
  37                         foreach($v as $s => $d) { 
  38                                 //Set is as parameters 
  39                                 $container->setParameter($alias.'.'.$k.'.'.$s, $d); 
  47         public function getAlias() { 
  52          * The function that parses the array to flatten it into a one level depth array 
  54          * @param $array        The config values array 
  55          * @param $path         The current key path 
  56          * @param $depth        The maxmium depth 
  57          * @param $sep          The separator string 
  59         /*protected function flatten($array, $path, $depth = 10, $sep = '.') { 
  63                 //Pass through non hashed or empty array 
  64                 if ($depth && is_array($array) && ($array === [] || array_keys($array) === range(0, count($array) - 1))) { 
  66                 //Flatten hashed array 
  67                 } elseif ($depth && is_array($array)) { 
  68                         foreach($array as $k => $v) { 
  69                                 $sub = $path ? $path.$sep.$k:$k; 
  70                                 $res += $this->flatten($v, $sub, $depth - 1, $sep); 
  72                 //Pass scalar value directly