MessageCommand
class MessageCommand implements CommandInterface, CommandWithAttachedAssetsInterface (View source)
AJAX command for a JavaScript Drupal.message() call.
Developers should be extra careful if this command and
\Drupal\Core\Ajax\AnnounceCommand are included in the same response. Unless
the announce option is set to an empty string (''), this command will
result in the message being announced to screen readers. When combined with
AnnounceCommand, this may result in unexpected behavior. Manual testing with
a screen reader is strongly recommended.
Here are examples of how to suppress announcements:
Properties
| protected string | $message | The message text. |
|
| protected bool | $clearPrevious | Whether to clear previous messages. |
|
| protected string | $wrapperQuerySelector | The query selector for the element the message will appear in. |
|
| protected array | $options | The options passed to Drupal.message().add(). |
Methods
Constructs a MessageCommand object.
Return an array to be run through json_encode and sent to the client.
Gets the attached assets.
Details
__construct(string $message, string|null $wrapper_query_selector = NULL, array $options = [], bool $clear_previous = TRUE)
Constructs a MessageCommand object.
render()
Return an array to be run through json_encode and sent to the client.
AttachedAssets|null
getAttachedAssets()
Gets the attached assets.