Skip to content

Commit

Permalink
Changed the flash message handling to use the non-deprecated api
Browse files Browse the repository at this point in the history
This fixes the compatibility with symfony 2.3
  • Loading branch information
stof committed May 25, 2013
1 parent 6b4e4a2 commit 90cb9c1
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\UserBundle\Model\User;

/**
* @author Antoine Hérault <antoine.herault@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\UserBundle\Model\User;

/**
* CreateUserCommand
Expand Down
1 change: 0 additions & 1 deletion Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\UserBundle\Model\User;

/**
* @author Matthieu Bontemps <matthieu@knplabs.com>
Expand Down
1 change: 0 additions & 1 deletion Command/DeactivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\UserBundle\Model\User;

/**
* @author Antoine Hérault <antoine.herault@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion Controller/ChangePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ protected function getRedirectionUrl(UserInterface $user)
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
$this->container->get('session')->getFlashBag()->set($action, $value);
}
}
2 changes: 1 addition & 1 deletion Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ protected function getEngine()
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
$this->container->get('session')->getFlashBag()->set($action, $value);
}
}
2 changes: 1 addition & 1 deletion Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ protected function getRedirectionUrl(UserInterface $user)
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
$this->container->get('session')->getFlashBag()->set($action, $value);
}
}
2 changes: 1 addition & 1 deletion Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function authenticateUser(UserInterface $user, Response $response)
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
$this->container->get('session')->getFlashBag()->set($action, $value);
}

protected function getEngine()
Expand Down
2 changes: 1 addition & 1 deletion Controller/ResettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected function getObfuscatedEmail(UserInterface $user)
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->setFlash($action, $value);
$this->container->get('session')->getFlashBag()->set($action, $value);
}

protected function getEngine()
Expand Down
2 changes: 1 addition & 1 deletion Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function loginAction()
$request = $this->container->get('request');
/* @var $request \Symfony\Component\HttpFoundation\Request */
$session = $request->getSession();
/* @var $session \Symfony\Component\HttpFoundation\Session */
/* @var $session \Symfony\Component\HttpFoundation\Session\Session */

// get the error if any (works with forward and redirect -- see below)
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
Expand Down
10 changes: 6 additions & 4 deletions Resources/views/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
{% endif %}
</div>

{% for key, message in app.session.getFlashes() %}
<div class="{{ key }}">
{{ message|trans({}, 'FOSUserBundle') }}
</div>
{% for type, messages in app.session.flashBag.all %}
{% for message in messages %}
<div class="{{ type }}">
{{ message|trans({}, 'FOSUserBundle') }}
</div>
{% endfor %}
{% endfor %}

<div>
Expand Down

0 comments on commit 90cb9c1

Please sign in to comment.