Download the PHP package arturdoruch/flash-message-bundle without Composer
On this page you can find all versions of the php package arturdoruch/flash-message-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arturdoruch/flash-message-bundle
More information about arturdoruch/flash-message-bundle
Files in arturdoruch/flash-message-bundle
Package flash-message-bundle
Short Description Flash message notification bundle for Symfony.
License MIT
Informations about the package flash-message-bundle
FlashMessageBundle
FlashMessageBundle allows in very convenient way sets or adds flash messages.
It's helpful, when we want to give user some response information about controller action status.
Flash message manager working with Symfony\Component\HttpFoundation\Session\Flash\FlashBag
and every setting message is automatically translated by Symfony\Component\Translation\Translation
.
Installation
Install bundle with composer
Add bundle to application kernel.
Configuration
This bundle configured under the artur_doruch_flash_message
key in your application configuration.
classes
type: array default:
An array of key-value pairs, where key is a message type and value a css class name. This parameter allows to define string that can be used in template as CSS class name for stylize displaying messages.
To use this parameter in template call ad_flash_messages_class_name(type)
function with message type as parameter.
See Resources/views/messages.html.twig
file.
Controller
Every message setting by service ad_flash_message
is automatically translated by Symfony\Component\Translation\Translation
.
To get flash message service.
Set, add messages
By default flash messages are translated with "messages" domain.
Methods starting with name "add" or "set", adds or sets messages to Symfony\Component\HttpFoundation\Session\Flash\FlashBag
, which next we can display in view template.
Difference between methods "set" and "add" is obvious. "add" adds new message into flashBag array collection, while "set" override existing array messages collection by new one.
Get messages
Methods starting with name "get" only prepare message and returns it without adding to Symfony\Component\HttpFoundation\Session\Flash\FlashBag
.
It's useful if you want to return translated message. For example if you work with REST api or Ajax request.
Instead sets $type by hand you can use these convenient methods.
Add or get messages for CRUD actions.
FlashMessageBundle provides methods for the easy way setting flash messages, when we're doing repetitive CRUD operations.
Messages for CRUD action are translated with "crudMessages" domain.
See Resources/translations/crudMessages.en.yml
file in this bundle.
Example usage
CRUD example.
View
Usage
For displaying flash messages just write this line of code into your base template file or wherever you want.
Optional
This function returns CSS class name related to given message type parameter. Helps to customize displaying messages by CSS style. See how configuration CSS classes names.
Of course you can customize whole messages template by overriding Resources/views/messages.html.twig
file.
To do this put template file into app/Resources/ArturDoruchFlashMessageBundle/views/messages.html.twig
location in your Symfony app.