class AlertCommand

AJAX command for a javascript alert box.

Hierarchy

Expanded class hierarchy of AlertCommand

1 file declares its use of AlertCommand
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/AlertCommand.php, line 15
Definition of Drupal\Core\Ajax\AlertCommand.

Namespace

Drupal\Core\Ajax
View source
class AlertCommand implements CommandInterface {

  /**
   * The text to be displayed in the alert box.
   *
   * @var string
   */
  protected $text;

  /**
   * Constructs an AlertCommand object.
   *
   * @param string $text
   *   The text to be displayed in the alert box.
   */
  public function __construct($text) {
    $this->text = $text;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
AlertCommand::$text protected property The text to be displayed in the alert box.
AlertCommand::render public function Implements Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
AlertCommand::__construct public function Constructs an AlertCommand object.