xm / flash-bundle
Makes adding & translating flash messages in Symfony simple.
Installs: 290
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.6 || ^7.0
- symfony/framework-bundle: ~3.0
- symfony/translation: ~3.0
Requires (Dev)
- mockery/mockery: ^0.9
- phpunit/phpunit: 5.7.*
- symfony/phpunit-bridge: ^3.0
- symfony/var-dumper: ^3.0
This package is auto-updated.
Last update: 2024-11-15 15:37:16 UTC
README
Makes adding & translating flash messages in Symfony simple.
Installation
Step 1: Download the Bundle
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.
Step 2: Enable the Bundle
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(), ); // ... } }
Step 3: Add Service Alias
Adding the following will make the call to the service shorter:
flash_handler: '@xm_flash.handler'
Usage
The handler will always pull messages from the default translation file, typically messages.
Just a message, no translation:
$this->get('flash_handler')->add('success', 'The record was saved.');
With translation message key and parameters:
$this->get('flash_handler')->add('success', 'app.message.entity_updated', ['%name%' => 'User']);