function UrlGeneratorTrait::redirect
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.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0. Use new RedirectResponse(Url::fromRoute()) instead.
3 methods override UrlGeneratorTrait::redirect()
- ControllerBase::redirect in core/
lib/ Drupal/ Core/ Controller/ ControllerBase.php - Returns a redirect response object for the specified route.
- EntityController::redirect in core/
lib/ Drupal/ Core/ Entity/ Controller/ EntityController.php - Returns a redirect response object for the specified route.
- FormBase::redirect in core/
lib/ Drupal/ Core/ Form/ FormBase.php - Returns a redirect response object for the specified route.
File
-
core/
lib/ Drupal/ Core/ Routing/ UrlGeneratorTrait.php, line 65
Class
- UrlGeneratorTrait
- Wrapper methods for the Url Generator.
Namespace
Drupal\Core\RoutingCode
protected function redirect($route_name, array $route_parameters = [], array $options = [], $status = 302) {
@trigger_error(__NAMESPACE__ . "\\UrlGeneratorTrait::redirect() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use new RedirectResponse(Url::fromRoute()) instead. See https://www.drupal.org/node/2614344", E_USER_DEPRECATED);
$options['absolute'] = TRUE;
$url = $this->getUrlGenerator()
->generateFromRoute($route_name, $route_parameters, $options);
return new RedirectResponse($url, $status);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.