W3cubDocs

/Drupal 8

protected function UrlGeneratorTrait::redirect

protected UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)

Returns a redirect response object for the specified route.

Parameters

string $route_name: The name of the route to which to redirect.

array $route_parameters: (optional) Parameters for the route.

array $options: (optional) An associative array of additional options.

int $status: (optional) The HTTP redirect status code for the redirect. The default is 302 Found.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect response object that may be returned by the controller.

File

core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 61

Class

UrlGeneratorTrait
Wrapper methods for the Url Generator.

Namespace

Drupal\Core\Routing

Code

protected function redirect($route_name, array $route_parameters = [], array $options = [], $status = 302) {
  $options['absolute'] = TRUE;
  $url = $this->url($route_name, $route_parameters, $options);
  return new RedirectResponse($url, $status);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!UrlGeneratorTrait.php/function/UrlGeneratorTrait::redirect/8.1.x