Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Last active July 15, 2016 21:29
Show Gist options
  • Save nietzscheson/b05a320a3b044bdd3382 to your computer and use it in GitHub Desktop.
Save nietzscheson/b05a320a3b044bdd3382 to your computer and use it in GitHub Desktop.
[#Symfony] - MessengerFlash
<?php
namespace AppBundle\Utils;
use Symfony\Component\HttpFoundation\Session\Session;
class MessengerFlash
{
private $session;
public function __construct(Session $session)
{
$this->session = $session;
}
public function add($type, $msn)
{
return $this->session->getFlashBag()->add($type, $msn);
}
}
app.messenger_flash:
class: AppBundle\Utils\MessengerFlash
arguments: [@session]
{% for flashMessage in app.session.flashbag.get('type') %}
<div class="alert alert-{{ app.session.flashbag.get('type') }} alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>{{ flashMessage }}</strong>
</div>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment