Skip to research

Gestion des messages (après drupal_set_message)

Reading time
Less than a minute
Étiquettes

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. Either self::TYPE_STATUS, self::TYPE_WARNING, or self::TYPE_ERROR.

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

$messenger = \Drupal::messenger();
$messenger->addMessage('STUFF', $messenger::TYPE_WARNING);

Ou

\Drupal::messenger()->addStatus('Cache rebuild complete.');
\Drupal::messenger()->addWarning(t(' View %name not found.', ['%name' => $view_name]));
\Drupal::messenger()->addError(t('The user %id does not exist.', ['%id' => $uid]));