I want to alter the message that is output in the message area. A typical message may look like this.
"Article My article has been created."
I’ve tried to put the following in hook_node_insert
:
$messages = Drupal::messenger()->all(); dpm($messages, 'messages');
It outputs an empty array: messages => []
.
I guess this is because the messages has not been created yet at this point in time.
Is there another hook I can use? I guess it must be fired after the node has been inserted, and before the page with the new article is displayed.
This similar question for Drupal 7 How do I change/modify an update content message suggests hook_message_alter()
. I haven’t found that, or a replacement, for Drupal 9.