Skip to content

Commit b5e0c49

Browse files
committed
Add docs for FlashMessageImportanceMapper
1 parent e7acfd9 commit b5e0c49

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

notifier.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,30 @@ and
662662
:class:`Symfony\\Component\\Notifier\\Notification\\EmailNotificationInterface`
663663
also exists to modify messages sent to those channels.
664664

665+
Customize Browser Notifications (Flash Messages)
666+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
667+
668+
The default behaviour for Browser channel notifications is to add a flash
669+
message with a key of "notification".
670+
671+
However, it may be desirable to map the importance level of the notification
672+
to the type of flash message, so that you can style the different flash
673+
messages according to their importance.
674+
675+
This can be done by overriding the default
676+
'notifier.flash_message_importance_mapper' service with your own implementation of
677+
:class:`Symfony\\Component\\Notifier\\FlashMessage\\FlashMessageImportanceMapperInterface`
678+
where you can provide your own "importance" to "alert level" mapping.
679+
680+
Symfony currently provides an implementation for the Bootstrap CSS framework's
681+
typical alert levels, which you can implement immediately using:
682+
683+
.. code-block:: yaml
684+
685+
# config/services.yaml
686+
services:
687+
notifier.flash_message_importance_mapper: Symfony\Component\Notifier\FlashMessage\BootstrapFlashMessageImportanceMapper
688+
665689
Disabling Delivery
666690
------------------
667691

0 commit comments

Comments
 (0)