class RedirectCommand

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

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

Hierarchy

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

File

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

Namespace

Drupal\Core\Ajax
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,
        ];
    }

}

Members

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.