Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (50 sloc) 1.5 KB

Add Notifications in a Controller

   // Get your session service
   $session = $this->get('session');

   // Add a success notification
   $session->getFlashBag()->add('ehann.notice.success', 'Update successful!');

   // Add an informational notification
   $session->getFlashBag()->add('ehann.notice.info', 'btw, you\'re awesome');

   // Add an warning notification
   $session->getFlashBag()->add('ehann.notice.warning', 'Something might be wrong!');

   // Add an error notification
   $session->getFlashBag()->add('ehann.notice.error', 'You broke something!');

Show Notification in a Twig Template

The notification extension takes 3 arguments...

  1. Message type: all|success|info|warning|error (default: all)
  2. Show icons: boolean (default: false)
  3. Repeat messages: boolean (default: true)

Show all notifications...

{{ notification()|raw }}

or

{{ notification('all')|raw }}

Show notifications individually...

{{ notification('success')|raw }}

{{ notification('info')|raw }}

{{ notification('warning')|raw }}

{{ notification('error')|raw }}

Show all notifications with icons...

{{ notification('all', true)|raw }}

Show notifications individually with icons...

{{ notification('success', true)|raw }}

{{ notification('info', true)|raw }}

{{ notification('warning', true)|raw }}

{{ notification('error', true)|raw }}

Do not show duplicate messages...

{{ notification('all', true, false)|raw }}