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.
Parameters
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'
Deprecated
in 8.x-3.18 and will be removed in a future release. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
See Also
Class
- Bootstrap
- The primary class for the Drupal Bootstrap base theme.
Namespace
Drupal\bootstrapSource 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);
}
}