Closed
Description
Routes can have additional options, like this:
some_route:
pattern: /my/nice/pattern
defaults: { _controller: MyBundle:MyController:MyAction }
options:
foo: 'bar'
To access routing options in a controller you need to call $this->get('router')->getRouteCollection()->get($routeName)->getOptions()
. However, getRouteCollection()
is a very expensive call and destroys all route caching advantages, even in prod env.
It is not clear for a developer that routing options are not meant to be used in a controller. The only place this is mentioned seems to be in #4436.
There should be either 1) a more efficient way to access route options or 2) a clearer best practice guide on what route options are meant to be used for and what the alternatives are.