Notification messages

Magento implements the notification message mechanism via the Messages module. The Messages module conforms to \Magento\Framework\Message\ManagerInterface. Though the interface itself does not impose any session relation, an implementation adds interface-defined types of messages to a session and allows access to those messages later. In the app/etc/di.xml file, there is a preference defined for \Magento\Framework\Message\ManagerInterface towards the Magento\Framework\Message\Manager class.

Message\ManagerInterface specifies four types of messages, namely error, warning, notice, and success. The types of messages are followed by several key methods in the Message\Manager class, such as addSuccess, addNotice, addWarning,

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.