class RedirectCommand

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Ajax/RedirectCommand.php \Drupal\Core\Ajax\RedirectCommand
  2. 8.9.x core/lib/Drupal/Core/Ajax/RedirectCommand.php \Drupal\Core\Ajax\RedirectCommand
  3. 10 core/lib/Drupal/Core/Ajax/RedirectCommand.php \Drupal\Core\Ajax\RedirectCommand

Defines an AJAX command to set the window.location, loading that URL.


Expanded class hierarchy of RedirectCommand

Related topics

2 files declare their use of RedirectCommand
AjaxCommandsTest.php in core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
BlockEntitySettingTrayForm.php in core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php


core/lib/Drupal/Core/Ajax/RedirectCommand.php, line 10


View source
class RedirectCommand implements CommandInterface {
     * The URL that will be loaded into window.location.
     * @var string
    protected $url;
     * Constructs an RedirectCommand object.
     * @param string $url
     *   The URL that will be loaded into window.location. This should be a full
     *   URL.
    public function __construct($url) {
        $this->url = $url;
     * Implements \Drupal\Core\Ajax\CommandInterface:render().
    public function render() {
        return [
            'command' => 'redirect',
            'url' => $this->url,



Title Sort descending Modifiers Object type Summary Overriden Title
RedirectCommand::$url protected property The URL that will be loaded into window.location.
RedirectCommand::render public function Implements \Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
RedirectCommand::__construct public function Constructs an RedirectCommand object.

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