Answer the question
In order to leave comments, you need to log in
How to use get parameters in route anotations sf2?
Hello.
There is such a route;
/**
* @Route("/search.{_format}/media/{tagName}",
* name="searchMedia",
* requirements= {
* "size":"thumbnail|low_resolution|standard_resolution",
* "tagName":"\w+",
* "count":"\d+",
* "tagId":"\d+",
* "_format":"web|json"
* },
* defaults={
* "count" : "33",
* "tagId" : "0",
* "size":"thumbnail",
* "_format":"web"
* }
* )
*/
/**
* @Route("/search.{_format}/media/{tagName}",
* name="searchMedia",
* requirements= {
* " GET(size)":"thumbnail|low_resolution|standard_resolution",
* "tagName":"\w+",
* "GET(count)":"\d+",
* "GET(tagId)":"\d+",
* "_format":"web|json"
* },
* defaults={
* "GET(count)" : "33",
* "GET(tagId)" : "0",
* "GET(size)":"thumbnail",
* "_format":"web"
* }
* )
*/
Answer the question
In order to leave comments, you need to log in
{{ path(name, parameters, relative) }}
name
type: string
parameters
type: array default: []
relative
type: boolean default: false
{{ path('searchMedia', ({tagName: tag.name,param1:"value1",tagId:"100500"})) }}
{{ path('searchMedia', (...)) }} brackets?
{{ path('searchMedia', {tagName: tag.name, param1:"value1", tagId:"100500"} ) }}
size, count, tagId in requirements are ignored as they are not in /search.{_format} /media/{tagName}
It seems to me or you have extra brackets here:
It should be like this:
{{ path('searchMedia', {tagName: tag.name,param1:"value1",tagId:"100500"}) }}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question