function ControllerBase::redirect

Same name in other branches
  1. 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::redirect()
  2. 8.9.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::redirect()
  3. 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.

23 calls to ControllerBase::redirect()
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.
LocaleController::checkTranslation in core/modules/locale/src/Controller/LocaleController.php
Checks for translation updates and displays the translations status.
MigrateController::showLog in core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
Sets a log filter and redirects to the log.

... See full list

File

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

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.