redirectAction() public méthode

It expects a route path parameter. By default, the response status code is 301. If the route empty, the status code will be 410. If the permanent path parameter is set, the status code will be 302.
public redirectAction ( string $route, boolean $permanent = false ) : Response
$route string The route pattern to redirect to
$permanent boolean Whether the redirect is permanent or not
Résultat Symfony\Component\HttpFoundation\Response A Response instance
 /**
  * Redirects to another route with the given name.
  *
  * The response status code is 302 if the permanent parameter is false (default),
  * and 301 if the redirection is permanent.
  *
  * In case the route name is empty, the status code will be 404 when permanent is false
  * and 410 otherwise.
  *
  * @param Request    $request          The request instance
  * @param string     $route            The route name to redirect to
  * @param bool       $permanent        Whether the redirection is permanent
  * @param bool|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore
  * @param array|bool $ignoreQueryString
  *
  * @return RedirectResponse A Response instance
  *
  * @throws HttpException In case the route name is empty
  */
 public function redirectAction(Request $request, $route, $permanent = false, $ignoreAttributes = false, $ignoreQueryString = false)
 {
     if ($ignoreAttributes !== true) {
         $ignoreAttributes[] = 'ignoreQueryString';
     }
     /** @var RedirectResponse $response */
     $response = parent::redirectAction($request, $route, $permanent, $ignoreAttributes);
     // If the query string is irrelevant then don't manipulate
     if ($ignoreQueryString === true) {
         return $response;
     }
     $queryString = $request->getQueryString();
     if (is_array($ignoreQueryString)) {
         $pairs = explode('&', $queryString);
         foreach ($pairs as $index => $pair) {
             list($key) = explode('=', $pair);
             if (in_array($key, $ignoreQueryString)) {
                 unset($pairs[$index]);
             }
         }
         $queryString = implode('&', $pairs);
     }
     $targetUrl = $response->getTargetUrl();
     if ($queryString) {
         if (strpos($targetUrl, '?') === false) {
             $targetUrl .= '?' . $queryString;
         } else {
             $targetUrl .= '&' . $queryString;
         }
     }
     $response->setTargetUrl($targetUrl);
     return $response;
 }
 /**
  * @dataProvider provider
  */
 public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expectedAttributes)
 {
     $request = new Request();
     $route = 'new-route';
     $url = '/redirect-url';
     $attributes = array('route' => $route, 'permanent' => $permanent, '_route' => 'current-route', '_route_params' => array('route' => $route, 'permanent' => $permanent, 'additional-parameter' => 'value', 'ignoreAttributes' => $ignoreAttributes));
     $request->attributes = new ParameterBag($attributes);
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $router->expects($this->once())->method('generate')->with($this->equalTo($route), $this->equalTo($expectedAttributes))->will($this->returnValue($url));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->once())->method('get')->with($this->equalTo('router'))->will($this->returnValue($router));
     $controller = new RedirectController();
     $controller->setContainer($container);
     $returnResponse = $controller->redirectAction($request, $route, $permanent, $ignoreAttributes);
     $this->assertRedirectUrl($returnResponse, $url);
     $this->assertEquals($expectedCode, $returnResponse->getStatusCode());
 }
 /**
  * @dataProvider provider
  */
 public function testRoute($permanent, $expectedCode)
 {
     $request = new Request();
     $route = 'new-route';
     $url = '/redirect-url';
     $params = array('additional-parameter' => 'value');
     $request->attributes = new ParameterBag(array('route' => $route, '_route' => 'current-route', 'permanent' => $permanent) + $params);
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $router->expects($this->once())->method('generate')->with($this->equalTo($route), $this->equalTo($params))->will($this->returnValue($url));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->at(0))->method('get')->with($this->equalTo('request'))->will($this->returnValue($request));
     $container->expects($this->at(1))->method('get')->with($this->equalTo('router'))->will($this->returnValue($router));
     $controller = new RedirectController();
     $controller->setContainer($container);
     $returnResponse = $controller->redirectAction($route, $permanent);
     $this->assertInstanceOf('\\Symfony\\Component\\HttpFoundation\\Response', $returnResponse);
     $this->assertTrue($returnResponse->isRedirect($url));
     $this->assertEquals($expectedCode, $returnResponse->getStatusCode());
 }