AlertCommand.php

Definition of Drupal\Core\Ajax\AlertCommand.

Namespace

Drupal\Core\Ajax

File

drupal/core/lib/Drupal/Core/Ajax/AlertCommand.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of Drupal\Core\Ajax\AlertCommand.
  5. */
  6. namespace Drupal\Core\Ajax;
  7. use Drupal\Core\Ajax\CommandInterface;
  8. /**
  9. * AJAX command for a javascript alert box.
  10. */
  11. class AlertCommand implements CommandInterface {
  12. /**
  13. * The text to be displayed in the alert box.
  14. *
  15. * @var string
  16. */
  17. protected $text;
  18. /**
  19. * Constructs an AlertCommand object.
  20. *
  21. * @param string $text
  22. * The text to be displayed in the alert box.
  23. */
  24. public function __construct($text) {
  25. $this->text = $text;
  26. }
  27. /**
  28. * Implements Drupal\Core\Ajax\CommandInterface:render().
  29. */
  30. public function render() {
  31. return array(
  32. 'command' => 'alert',
  33. 'text' => $this->text,
  34. );
  35. }
  36. }

Classes

Namesort descending Description
AlertCommand AJAX command for a javascript alert box.