Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony redirect with request

I want to redirect and send my request to another route but this method is not working.

 return $this->redirect($this->generateUrl(
    'admin_platform_create', 
    array('request' => $request)
 ));

When I arrive into admin_platform_create it doesn't pass that if

public function createAction(Request $request)
    {    
        if ($request->getMethod() == 'POST')
            {

Though this is working,

  return $this->forward('AdminPlatformBundle:Manage:edit',
    array('request' => $request));

It is not what I need as it is not writing the new URL.

Thanks for your help!

like image 965
Hewyn Avatar asked Apr 17 '15 10:04

Hewyn


1 Answers

If you are using Symfony 2.6 or later, you can do it:

return $this->redirectToRoute('route', [
    'request' => $request
], 307);
like image 122
Oleksandr Yarushevskyi Avatar answered Oct 23 '22 12:10

Oleksandr Yarushevskyi