Skip to content

docs: Port "Flash messages" page to 7.2#573

Open
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/docs-issue-403-flash-messages-7.2
Open

docs: Port "Flash messages" page to 7.2#573
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/docs-issue-403-flash-messages-7.2

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

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


Tip: Adjust how proactive or focused Promptless is in Agent Settings ⚙️

@promptless-for-oss
promptless-for-oss requested a review from a team July 10, 2026 09:45

.. vale off

Controllers that extend one of :ref:`Mautic's common controllers<plugins/mvc:Controllers>` can use the ``addFlashMessage()`` helper:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant