2017 © Pedro Peláez
 

symfony-bundle flash-alert-bundle

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

image

ras/flash-alert-bundle

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  • Monday, September 5, 2016
  • by ras
  • Repository
  • 4 Watchers
  • 26 Stars
  • 17,013 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 10 Forks
  • 6 Open issues
  • 9 Versions
  • 1 % Grown

The README.md

FlashAlertBundle

FlashAlertBundle is an open source Bundle which simplifies displaying flash alerts such as success, error, info and warning, (*1)

Build Status Scrutinizer Code Quality, (*2)

Demo screenshot, (*3)

Table of Contents

  1. Installation
    1. Download the FlashAlertBundle
    2. Enable the bundle
    3. Configure the bundle
  2. Usage
    1. Report flash alerts
    2. Display flash alerts
  3. Configuration
    1. Override view template
    2. Add custom styles
  4. Changelog
  5. License

Installation

Step 1: Download the FlashAlertBundle

Using Composer Add the following to the "require" section of your composer.json file:, (*4)

    "ras/flash-alert-bundle": "dev-master"

And update your dependencies, (*5)

    php composer.phar update

Using submodules Execute the following command on your project root: ``` bash $ git submodule add git@github.com:rasanga/FlashAlertBundle.git vendor/bundles/Ras/FlashAlertBundle $ git submodule update --init, (*6)


### Step 2: Enable the bundle Registers the bundle in your `app/AppKernel.php`: ```php <?php ... public function registerBundles() { $bundles = array( ... new Ras\Bundle\FlashAlertBundle\RasFlashAlertBundle(), ... ); ...

Step Optional, if you are not using composer: Configure the Autoloader

Add the following to your autoload.php:, (*7)

<?php
...
'Ras' => __DIR__.'/../vendor/bundles',

Usage

Report flash alerts

Add the following PHP code to report an alert message:, (*8)

    $this->get('ras_flash_alert.alert_reporter')->addError("Access denied");

Note: You can choose one of the following functions to call from $this->get('ras_flash_alert.alert_reporter'), (*9)

    addSuccess()
    addError()
    addWarning()
    addInfo()

Display flash alerts

Add the following twig code where you want to display alert messages:, (*10)

    {{ render_flash_alerts() }}

Note 1: The parent twig template would be the best place for displaying flash alerts, (*11)

Configuration

The following parameters can be overriden in your config.yml or similar:, (*12)

ras_flash_alert:
    template: '::flashAlerts.html.twig'     # defaults to 'RasFlashAlertBundle::layout.html.twig'
    isAddStyles: false                      # defaults to true
    isAddJsAlertClose: false                # defaults to true

These can also be passed as parameters in the view when rendering alerts - for example:, (*13)

    {{ render_flash_alerts({ 'template': '::flashAlerts.html.twig', 'isAddStyles': false }) }}

Override view template

  1. Crete template in the /Resources/views/ or in your bundle
  2. Retrieve alerts into your template with {{ get_alert_publisher() }}
  3. Include template blocks in FlashAlertBundle/Resources/views/FlashAlert directory or define your own blocks (follow FlashAlertBundle/Resources/views/FlashAlert/flashAlerts.html.twig to see how you can define your own template)

Add custom styles

The bundle default template has styles defined by default. However, you can turn off default styles by configuring isAddStyles variable to false as shown in below., (*14)

    {{ render_flash_alerts({ 'isAddStyles': false }) }}

Then you can define your own styles to match alert classes such as alert, alert-close, alert-success, alert-error, alert-warning and alert-info, (*15)

CHANGELOG

2.0

Add twig method for rendering alerts: `{{ render_flash_alerts() }}`
Add twig method for retrieving alerts: `{{ get_alert_publisher() }}`
Deprecated controller view render 

LICENSE

FlashAlertBundle is licensed under the MIT Open Source license., (*16)

Bitdeli Badge, (*17)

The Versions

05/09 2016

dev-development

dev-development http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

03/01 2016

2.1.1

2.1.1.0 http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

03/01 2016

dev-master

9999999-dev http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

03/01 2016

dev-development_v2

dev-development_v2 http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

03/01 2016

dev-patch-1

dev-patch-1 http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

25/06 2015

v2.1

2.1.0.0 http://rasanga.github.io/FlashAlertBundle/

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

18/12 2014

v2.0

2.0.0.0

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

13/09 2014

v1.0

1.0.0.0

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

  Sources   Download

MIT

The Requires

 

by Rasanga Perera

bundle symfony message notification feedback alert flash

02/09 2014

v0.1

0.1.0.0

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Rasanga Perera

bundle symfony message notification feedback alert flash