Jun 19, 2019 in Drupal 8, Snippets

Drupal set message was deprecated in Drupal 8.5 and will be removed before Drupal 9. Time for a roundup of this new API and how to use it.

\Drupal::messenger()->addMessage('This is a regular message');
\Drupal::messenger()->addStatus('This is a status message, meaning status is OK or successful (green).');
\Drupal::messenger()->addError('This is an error message (red)');
\Drupal::messenger()->addWarning('This is a warning message (orange)');

For more about this API, take a look at this page at drupal.org.