Makes adding & translating flash messages in Symfony simple.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ php composer.phar require xm/flash-bundle
This command requires Composer.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new XM\FlashBundle\XMFlashBundle(),
);
// ...
}
}
Adding the following will make the call to the service shorter:
flash_handler: '@xm_flash.handler'
The handler will always pull messages from the default translation file, typically messages.
$this->get('flash_handler')->add('success', 'The record was saved.');
$this->get('flash_handler')->add('success', 'app.message.entity_updated', ['%name%' => 'User']);