Reputation: 763
I want to generate url in my application from config params. I have folllowing config that I'm processing:
link:
route_name: article
route_params: {id: 1}
and my 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 to process array with route_params. Amount and names of params will be different in each routes, so I can't just do:
->arrayNode('route_params')
->scalarNode('id')->end()
->end()
I'm getting this error now:
Unrecognized option "id" under "link.route_params"
Upvotes: 0
Views: 140
Reputation: 803
Try something like this
->arrayNode('route_params')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
Upvotes: 1