Is it possible to forward a request, passing along all GET/POST params?
I think if I just do
$this->forward('dest')
I will go to dest without any GET/POST params?
UPDATE
My objective is actually to have a controller action like addSomething that takes checks that the user has the sufficient “items” to add something. Then forward the request to the approperiate controller to continue the actual adding of adding{Type}Something
Or would getting a “checking” service in all controllers that does the checking be more appropriate? Anyways, I think its informative to know how to forward to a controller action with all params
I don’t see any reason here to forward the request back through the kernel. You can go the route of encapsulating this logic in a checker service, as you’ve suggested, or you may be able to create a
kernel.requestlistener that runs after the router listener and applies the_controllerattribute only if your conditions are met.For example, this
routing.yml:And this listener:
Configured to run after the core router listener:
The priority of the core router listener is
0in Symfony 2.0 and32in Symfony 2.1. In either case, a priority of-10should work.I’m curious to see if this works 🙂