I use redirectToRoute in my controller, and i want to know how can i transfer URL parameters in this method (redirectToRoute) ?
I already search on the web (SF documentation and forums), but i didn't find the solution.
Thanks.
Let's look into source of this method:
/**
* Returns a RedirectResponse to the given route with the given parameters.
*
* @param string $route The name of the route
* @param array $parameters An array of parameters
* @param int $status The status code to use for the Response
*
* @return RedirectResponse
*/
protected function redirectToRoute($route, array $parameters = array(), $status = 302)
{
return $this->redirect($this->generateUrl($route, $parameters), $status);
}
As you can see the second argument is $parameters
.
So simply pass them as an array as second argument. So it should be used like:
$this->redirectToRoute('show_page', array('id' => 123));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With