ajt / flashbundle
Symfony bundle for for managing flash messages
Installs: 4 019
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- symfony/framework-bundle: *
- symfony/http-foundation: *
- twig/twig: *
Requires (Dev)
- matthiasnoback/symfony-config-test: *
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-10-26 15:49:42 UTC
README
The AJT Flash Bundle will manage the use of Symfony flash messages with a simple API.
Usage
Inject the Flash service into any service
<argument type="service" id="ajt.flash" />
Use it in service
class MyClass { private $flash; public function __construct(FlashInterface $flash) { $this->flash = $flash; } public function goThings() { ... $this->flash->success("Well done"); } }
Use the twig function in your template,
{{ ajt_flash() }}
Or if you want to only display some types of message
{{ ajt_flash('error') }}
Standard Types
By default the Flash bundle will support the standard bootstrap alert types.
// Set a custom type $flash->set('my message', 'myType'); // Bootstrap $flash->success('my message'); $flash->error('my message'); $flash->info('my message'); $flash->warning('my message');
Custom Css
Custom css classes can be set by modifying config.
ajt_flash: default_class: alert # Added to every flash # CSS to add to the standard flash types - default to bootstrap core: success: alert-success error: alert-danger info: alert-info warning: alert-warning # Add a custom flash type called myType with the css myCss custom: myType: type: myType css: myCss