Last active
July 15, 2016 21:29
-
-
Save nietzscheson/b05a320a3b044bdd3382 to your computer and use it in GitHub Desktop.
[#Symfony] - MessengerFlash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.messenger_flash: | |
class: AppBundle\Utils\MessengerFlash | |
arguments: [@session] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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