function public static function Bootstrap::message

8.x-3.x Bootstrap.php public static Bootstrap::message($message, $type = 'status', $repeat = FALSE)

Wrapper to use new Messenger service or the legacy procedural function.

This is to help support older installations without trigger deprecation notices for newer installations.


string|\Drupal\Component\Render\MarkupInterface $message: (optional) The translated message to be displayed to the user. For consistency with other messages, it should begin with a capital letter and end with a period.

string $type: (optional) The message's type. Defaults to 'status'. These values are supported:

  • 'status'
  • 'warning'
  • 'error'
bool $repeat: (optional) If this is FALSE and the message is already set, then the message won't be repeated. Defaults to FALSE.


in 8.x-3.18 and will be removed in a future release. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.


The primary class for the Drupal Bootstrap base theme.



Source src/Bootstrap.php (line 1352)

public static function message($message, $type = 'status', $repeat = FALSE) {
  if (!isset(static::$messenger)) {
    static::$messenger = \Drupal::hasService('messenger') ? \Drupal::service('messenger') : FALSE;
  if (static::$messenger) {
    static::$messenger->addMessage($message, $type, $repeat);
  else {
    drupal_set_message($message, $type, $repeat);