function Messenger::addMessage

Same name in other branches
  1. 9 core/lib/Drupal/Core/Messenger/Messenger.php \Drupal\Core\Messenger\Messenger::addMessage()
  2. 8.9.x core/lib/Drupal/Core/Messenger/Messenger.php \Drupal\Core\Messenger\Messenger::addMessage()
  3. 10 core/lib/Drupal/Core/Messenger/Messenger.php \Drupal\Core\Messenger\Messenger::addMessage()

Overrides MessengerInterface::addMessage

3 calls to Messenger::addMessage()
Messenger::addError in core/lib/Drupal/Core/Messenger/Messenger.php
Adds a new error message to the queue.
Messenger::addStatus in core/lib/Drupal/Core/Messenger/Messenger.php
Adds a new status message to the queue.
Messenger::addWarning in core/lib/Drupal/Core/Messenger/Messenger.php
Adds a new warning message to the queue.

File

core/lib/Drupal/Core/Messenger/Messenger.php, line 52

Class

Messenger
The messenger service.

Namespace

Drupal\Core\Messenger

Code

public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE) {
    if (!$message instanceof Markup && $message instanceof MarkupInterface) {
        $message = Markup::create((string) $message);
    }
    // Do not use strict type checking so that equivalent string and
    // MarkupInterface objects are detected.
    if ($repeat || !in_array($message, $this->flashBag
        ->peek($type))) {
        $this->flashBag
            ->add($type, $message);
    }
    // Mark this page as being uncacheable.
    $this->killSwitch
        ->trigger();
    return $this;
}

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