class RedirectCommand

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

Hierarchy

Expanded class hierarchy of RedirectCommand

1 file declares its use of RedirectCommand
AjaxCommandsUnitTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php
Definition of Drupal\system\Tests\Ajax\AjaxCommandsUnitTest.

File

drupal/core/lib/Drupal/Core/Ajax/RedirectCommand.php, line 15
Contains \Drupal\Core\Ajax\RedirectCommand.

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, one that has already been run through the url() function.
   */
  public function __construct($url) {
    $this->url = $url;
  }

  /**
   * Implements \Drupal\Core\Ajax\CommandInterface:render().
   */
  public function render() {
    return array(
      'command' => 'redirect',
      'url' => $this->url,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.