I've got the following route definition
my_route:
path: /actual-path/
defaults:
_controller: MyBundle:MyController:detail
id: application_id
requirements:
methods: GET
id: \d+
The controller requires a parameter called $id
.
But I don't want to use the $id
in the url, I want to use a value that is available in $request->attributes->get('application_id')
There is a listener that will inject two parameters (application_id
and application
) into the request object as attributes prior to the routing process, so this value is in there. (It would be easy to also inject it into the RequestContext
).
Is there a way I can use attributes values from the Request
or RequestContext
object in my routing as defaults?
Now I could simply do $request->attributes->get('application_id')
in my controller. But this controller will be used in several cases. In other cases the $id
is to be passed through the url. I find it cleaner to set the id in the routing than build a if-else clause in the controller somewhere.
id
, but the value in Request isapplication_id
. So basically, I would need some kind of mapping in the routing configuration. – DoppyNL