You are here

class JsRedirectCommand in JS Callback Handler 8.3

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

Hierarchy

Expanded class hierarchy of JsRedirectCommand

1 file declares its use of JsRedirectCommand
Js.php in src/Js.php

File

src/Ajax/JsRedirectCommand.php, line 12

Namespace

Drupal\js\Ajax
View source
class JsRedirectCommand implements CommandInterface {

  /**
   * Flag indicating whether redirection should be forced in the browser.
   *
   * @var bool
   */
  protected $force;

  /**
   * 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 in the browser. This should be a full URL.
   * @param bool $force
   *   Flag indicating whether redirection should be forced in the browser.
   */
  public function __construct($url, $force = FALSE) {
    $this->url = $url;
    $this->force = $force;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
JsRedirectCommand::$force protected property Flag indicating whether redirection should be forced in the browser.
JsRedirectCommand::$url protected property The URL that will be loaded into window.location.
JsRedirectCommand::render public function Implements \Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
JsRedirectCommand::__construct public function Constructs an RedirectCommand object.