diff --git a/CHANGELOG-2.1.md b/CHANGELOG-2.1.md
index 4b69f6a794..b6e0e7c55a 100644
--- a/CHANGELOG-2.1.md
+++ b/CHANGELOG-2.1.md
@@ -231,9 +231,9 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* Added `AutoExpireFlashBag` (default) to replicate Symfony 2.0.x auto expire behaviour of messages auto expiring
after one page page load. Messages must be retrived by `get()` or `all()`.
* Deprecated the following methods from the Session class: `close()`, `setFlash()`, `setFlashes()`
- `getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashes() instead which returns a `FlashBagInterface`.
+ `getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashBag() instead which returns a `FlashBagInterface`.
* `Session->clear()` now only clears session attributes as before it cleared flash messages and
- attributes. `Session->getFlashes()->all()` clears flashes now.
+ attributes. `Session->getFlashBag()->all()` clears flashes now.
* Added `Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage` base class for
session storage drivers.
* Added `Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface` interface
diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md
index 316efdff81..862806138b 100644
--- a/UPGRADE-2.1.md
+++ b/UPGRADE-2.1.md
@@ -268,15 +268,15 @@ UPGRADE FROM 2.0 to 2.1
After (PHP):
- getFlashes()->has('notice')): ?>
+ getFlashBag()->has('notice')): ?>
- getFlashes()->get('notice') ?>
+ getFlashBag()->get('notice') ?>
- If you wanted to process all flash types you could also make use of the `getFlashes()->all()` API:
+ If you wanted to process all flash types you could also make use of the `getFlashBag()->all()` API:
- getFlashes()->all() as $type => $flash): ?>
+ getFlashBag()->all() as $type => $flash): ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php
index 849002dd53..c6628172f2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php
@@ -48,17 +48,17 @@ class SessionHelper extends Helper
public function getFlash($name, $default = null)
{
- return $this->session->getFlashes()->get($name);
+ return $this->session->getFlashBag()->get($name);
}
public function getFlashes()
{
- return $this->session->getFlashes()->all();
+ return $this->session->getFlashBag()->all();
}
public function hasFlash($name)
{
- return $this->session->getFlashes()->has($name);
+ return $this->session->getFlashBag()->has($name);
}
/**
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php
index 626c2e2cbd..b1c4334cde 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php
@@ -51,7 +51,7 @@ class SessionController extends ContainerAware
{
$request = $this->container->get('request');
$session = $request->getSession();
- $session->getFlashes()->set('notice', $message);
+ $session->getFlashBag()->set('notice', $message);
return new RedirectResponse($this->container->get('router')->generate('session_showflash'));
}
@@ -61,8 +61,8 @@ class SessionController extends ContainerAware
$request = $this->container->get('request');
$session = $request->getSession();
- if ($session->getFlashes()->has('notice')) {
- $output = $session->getFlashes()->get('notice');
+ if ($session->getFlashBag()->has('notice')) {
+ $output = $session->getFlashBag()->get('notice');
} else {
$output = 'No flash was set.';
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
index 8f87603a6c..ce8c91b173 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php
@@ -26,7 +26,7 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
$session = new Session(new MockArraySessionStorage());
$session->set('foobar', 'bar');
- $session->getFlashes()->set('notice', 'bar');
+ $session->getFlashBag()->set('notice', 'bar');
$this->request->setSession($session);
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
index d6235025d0..96347eaf3a 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
@@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
/**
* ProfilerController.
@@ -146,9 +147,9 @@ class ProfilerController extends ContainerAware
{
$request = $this->container->get('request');
- if (null !== $session = $request->getSession()) {
- // keep current flashes for one more request
- $session->setFlashes($session->getFlashes());
+ if (null !== $session = $request->getSession() && $session instanceof AutoExpireFlashBag) {
+ // keep current flashes for one more request if using AutoExpireFlashBag
+ $session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if (null === $token) {
diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
index 5d172a1cad..9d615c9c5c 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
@@ -74,9 +74,7 @@ class WebDebugToolbarListener
$session = $request->getSession();
if ($session instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
- foreach ($session->getFlashKeys() as $type) {
- $session->setFlashes($session->getFlashes($type));
- }
+ $session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
$response->setContent($this->templating->render('WebProfilerBundle:Profiler:toolbar_redirect.html.twig', array('location' => $response->headers->get('Location'))));
diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php
index 8428266278..56ee1f0949 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Session.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Session.php
@@ -241,7 +241,7 @@ class Session implements SessionInterface
*
* @return FlashBagInterface
*/
- public function getFlashes()
+ public function getFlashBag()
{
return $this->getBag('flashes');
}