docs: Port "Flash messages" page to 7.2#573
Conversation
|
|
||
| .. vale off | ||
|
|
||
| Controllers that extend one of :ref:`Mautic's common controllers<plugins/mvc:Controllers>` can use the ``addFlashMessage()`` helper: |
There was a problem hiding this comment.
Corrected the legacy doc's addFlash() to the real helper addFlashMessage($message, $messageVars, $level, $domain, $addNotification) defined in CommonController, which delegates to FlashBag::add(). The legacy Markdown named a non-existent addFlash() method.
Source: https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Controller/CommonController.php
| } | ||
| } | ||
|
|
||
| Both ``addFlashMessage()`` and ``FlashBag::add()`` take a final ``$addNotification`` argument. Set it to ``true`` to add a matching entry to the notification center alongside the flash message. |
There was a problem hiding this comment.
Documented FlashBag::add($message, $messageVars = [], $level = self::LEVEL_NOTICE, $domain = 'flashes', $addNotification = false) and the LEVEL_NOTICE/LEVEL_ERROR/etc. constants from the FlashBag service, and confirmed $addNotification defaults to false (so a notification isn't created unless opted in).
Source: https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Service/FlashBag.php
| Notifications | ||
| ************* | ||
|
|
||
| Mautic also has a notification center. Adding a flash message doesn't create a notification by default, but you can opt in with the ``$addNotification`` flag described earlier, or add one on its own. To add a standalone notification, inject ``Mautic\CoreBundle\Model\NotificationModel`` and call its ``addNotification()`` method. |
There was a problem hiding this comment.
Replaced the legacy doc's controller addNotification() helper (which no longer exists on CommonController) with NotificationModel::addNotification(), the actual method for adding a standalone notification from a model or service.
Source: https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Model/NotificationModel.php
Open this suggestion in Promptless to view citations and reasoning process
Ports the legacy Flash messages developer guide into docs/plugin_miscellaneous/flash_messages.rst, converting the Markdown source to RST and updating it to the current 7.x FlashBag service API. Documents the controller addFlashMessage() helper, injecting FlashBag in services, the $addNotification flag, and NotificationModel for standalone notifications. Resolves porting issue #403 (source from parent #402), targeting the 7.2 base branch.
Trigger Events
blockedlabel is to set content, structure, and tone in one branch, then backport/cherry pick i...Tip: Adjust how proactive or focused Promptless is in Agent Settings ⚙️