8.5.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.0.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.1.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.2.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.3.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.4.x UrlGeneratorTrait.php UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302)
8.6.x UrlGeneratorTrait.php 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.

26 calls to UrlGeneratorTrait::redirect()
AggregatorController::feedRefresh in core/modules/aggregator/src/Controller/AggregatorController.php
Refreshes a feed, then redirects to the overview page.
AggregatorTestRssController::testRedirect in core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php
Generates a rest redirect to the test feed.
CommentController::redirectNode in core/modules/comment/src/Controller/CommentController.php
Redirects legacy node links to the new path.
CronController::runManually in core/modules/system/src/CronController.php
Run cron manually.
EntityController::addPage in core/lib/Drupal/Core/Entity/Controller/EntityController.php
Displays add links for the available bundles.

... See full list

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);
}