You are here

protected function ControllerBase::redirect in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::redirect()
  2. 10 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::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.

24 calls to ControllerBase::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.
BlockController::performOperation in core/modules/block/src/Controller/BlockController.php
Calls a method on a block and reloads the listing page.
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.

... See full list

File

core/lib/Drupal/Core/Controller/ControllerBase.php, line 274

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

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