php - Symfony tree builder process array -


i want generate url in application config params. have folllowing config i'm processing:

link:         route_name: article         route_params: {id: 1} 

and configuration:

->arraynode('link')     ->beforenormalization()         ->ifstring()         ->then(function ($v) { return [ 'direct' => $v]; })     ->end()     ->children()         ->scalarnode('route_name')->end()         ->arraynode('route_params')->end()         ->scalarnode('direct')->end()     ->end() ->end() 

i'm generating url by:

$this->router->generate($this->config['link']['route_name'],             $this->config['link']['route_params']); 

i don't know how process array route_params. amount , names of params different in each routes, can't do:

->arraynode('route_params')     ->scalarnode('id')->end() ->end() 

i'm getting error now:

unrecognized option "id" under "link.route_params"

try this

   ->arraynode('route_params')         ->useattributeaskey('name')         ->prototype('scalar')->end()     ->end() 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -