class AlertCommand

Same name in other branches
  1. 9 core/lib/Drupal/Core/Ajax/AlertCommand.php \Drupal\Core\Ajax\AlertCommand
  2. 10 core/lib/Drupal/Core/Ajax/AlertCommand.php \Drupal\Core\Ajax\AlertCommand
  3. 11.x core/lib/Drupal/Core/Ajax/AlertCommand.php \Drupal\Core\Ajax\AlertCommand

AJAX command for a javascript alert box.

Hierarchy

Expanded class hierarchy of AlertCommand

Related topics

6 files declare their use of AlertCommand
AjaxCommandsTest.php in core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
AjaxRenderer.php in core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
AjaxTestController.php in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
ajax_forms_test.module in core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
Simpletest mock module for Ajax forms testing.
FormAjaxResponseBuilderTest.php in core/tests/Drupal/Tests/Core/Form/FormAjaxResponseBuilderTest.php

... See full list

File

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

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 [
            'command' => 'alert',
            'text' => $this->text,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
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.

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