Closed
Description
One feature I'm often missing, is the ability to fetch query parameters directly from the method arguments. With the refactoring I've made it easier to add functionality, I was thinking to use this if the feature would be decided.
Current scenario
class FooController
{
/**
* Calling "/foo?bar=baz"
* @Route("/foo")
*/
public function fooAction(Request $request)
{
return new Response(sprintf('Your query was %s.', $request->query->get('bar')));
}
}
Proposed scenario
class FooController
{
/**
* Calling "/foo?bar=baz"
* @Route("/foo")
*/
public function fooAction(Request $request, $bar)
{
return new Response(sprintf('Your query was %s.', $bar'));
}
}
This should also support arrays and optional values for example:
class FooController
{
/**
* Calling "/foo?bar[]=baz&bar[]=hello-world"
* @Route("/foo")
*/
public function fooAction(Request $request, array $bar = [])
{
// ...
}
}
Would this be something I can add to the core? If not I can add it to my own bundle for people that do need it.