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
, addError
, and addException
. The addException
method is basically a wrapper for addError
that accepts an exception
object as a parameter.
Let's try to run the following code in the execute
method of app/code/Foggyline/Office/Controller/Test/Crud.php
:
$resultPage...