You are here

class WebformAnnounceCommand in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Ajax/WebformAnnounceCommand.php \Drupal\webform\Ajax\WebformAnnounceCommand

Provides an Ajax command to trigger audio UAs to read the supplied text.

This command is implemented in Drupal.AjaxCommands.prototype.webformAnnounce.

Hierarchy

Expanded class hierarchy of WebformAnnounceCommand

File

src/Ajax/WebformAnnounceCommand.php, line 12

Namespace

Drupal\webform\Ajax
View source
class WebformAnnounceCommand implements CommandInterface {

  /**
   * A string to be read by the UA.
   *
   * @var string
   */
  protected $text;

  /**
   * A string to indicate the priority of the message.
   *
   * Can be either 'polite' or 'assertive'.
   *
   * @var string
   */
  protected $priority;

  /**
   * Constructs a WebformAnnounceCommand object.
   *
   * @param string $text
   *   A string to be read by the UA.
   * @param string $priority
   *   A string to indicate the priority of the message. Can be either
   *   'polite' or 'assertive'.
   */
  public function __construct($text, $priority = 'polite') {
    $this->text = $text;
    $this->priority = $priority;
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      'command' => 'webformAnnounce',
      'text' => $this->text,
      'priority' => $this->priority,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformAnnounceCommand::$priority protected property A string to indicate the priority of the message.
WebformAnnounceCommand::$text protected property A string to be read by the UA.
WebformAnnounceCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render
WebformAnnounceCommand::__construct public function Constructs a WebformAnnounceCommand object.