8000 [HttpKernel] Support querystring in action arguments · Issue #19655 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[HttpKernel] Support querystring in action arguments #19655
Closed
@linaori

Description

@linaori

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0