Reputation: 2808
In symfony2, in the routing YAML configurations, you can have an array of options. It looks like this:
example_route:
pattern: /test/route
options:
option1: value1
option2: value2
Some of the routes however, are defined within Annotations instead for pretty specific reasons, but I need to add some "options" to those.
I only see a few fields for Annotations, like:
@Route and @Method
@ParamConverter
@Template
@Cache
@Security
and none of those appear to allow injection into the Route objects Options array.
Is there a solution to accomplish this?
Upvotes: 3
Views: 2920
Reputation: 942
Although it's not documented, the @Route annotation sets other route properties the using the same syntax as requirements and defaults:
/**
* @Route("/hello/{name}", name="hello_world", requirements={"name" = "\w+"}, defaults={"name" = "World"}, options={"option" = "value"})
*/
Upvotes: 5
Reputation: 1743
Do you mean route requirements? I don't think options: is a valid configuration for a route, but there is of course defaults, requirements, etc.
With annotations, the route requirement is part of the @Route attribute:
/**
* @Route("/hello/{name}", name="hello_world", requirements={"name" = "\w+"}, defaults={"name" = "World"})
*/
See http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html
Upvotes: 0