function ControllerBase::redirect
Same name in other branches
- 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::redirect()
- 10 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::redirect()
- 11.x 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.
Overrides UrlGeneratorTrait::redirect
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.
File
-
core/
lib/ Drupal/ Core/ Controller/ ControllerBase.php, line 303
Class
- ControllerBase
- Utility base class for thin controllers.
Namespace
Drupal\Core\ControllerCode
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.