3 namespace Rapsys\PackBundle\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 RapsysPackExtension
extends Extension
{
19 public function load(array $configs, ContainerBuilder
$container) {
21 #$loader = new Loader\YamlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
22 $loader = new Loader\
YamlFileLoader($container, new FileLocator('config/packages'));
23 $loader->load($this->getAlias().'.yaml');
26 $configuration = $this->getConfiguration($configs, $container);
27 $config = $this->processConfiguration($configuration, $configs);
29 //Set default config in parameter
30 if (!$container->hasParameter($alias = $this->getAlias())) {
31 $container->setParameter($alias, $config[$alias]);
32 //Fill missing entries
34 //Change in config flag
37 //Iterate on each user configuration keys
38 foreach($container->getParameter($alias) as $k => $v) {
39 //Check if value is an array
41 //Iterate on each array keys
42 foreach($v as $sk => $sv) {
43 //Check if sub value is an array
45 //TODO: implement sub sub key merging ? (or recursive ?)
46 @trigger_error('Nested level > 2 not yet implemented here', E_USER_ERROR
);
49 //Trigger changed flag
51 //Replace default value with user provided one
52 $config[$alias][$k][$sk] = $sv;
57 //Trigger changed flag
59 //Replace default value with user provided one
60 $config[$alias][$k] = $v;
64 //Check if change occured
67 $container->setParameter($alias, $config[$alias]);
75 public function getConfiguration(array $configs, ContainerBuilder
$container) {
76 //Get configuration instance with resolved public path
77 return new Configuration($container->getParameter('kernel.project_dir').'/public/');
83 public function getAlias() {