In my Magento2 module I want to create admin system messages that are sticky and show up on every page in the adminhtml until the problem is solved. It's something important that the admin needs to address, otherwise the store will be severely impacted. But once the detected problem was solved, the message should go away.
As an example I'm looking at the messages that tell me when indexers or caches need to be refreshed. How can I create messages like that?
I was looking at the core module AdminNotification
which seems to be uniquely responsible for this. It looked at the involved templates and blocks to display these messages, and that all makes sense, but where are they created? I can't seem to figure out how to create these notifications.
There is a db table called admin_system_messages
which stores something related to that, but I don't understand the content. The field identity
just contains a long hex number. I took such a number and searched for it over all code and the entire database to find references, but nothing turned up. How does the module extract "One or more of the Cache Types are invalidated [...]" from this?
To be clear, I have seen the mechanism to add temporary messages which will be shown to the user ONCE, such as the confirmations when you delete or save something and it tells you that it was successful. This is NOT what I'm looking for, I want permanent messages on every page. I know it's obtrusive, but I'm convinced it's necessary in my case.