Permalink
Browse files

renamed getFlashes() to getFlashBag() to avoid clashes

  • Loading branch information...
1 parent 282d3ae commit 8a01dd5cff02e2e77a0b138bf6ed2b5c4e73c16d @fabpot fabpot committed Feb 11, 2012
View
@@ -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
View
@@ -268,15 +268,15 @@ UPGRADE FROM 2.0 to 2.1
After (PHP):
- <?php if ($view['session']->getFlashes()->has('notice')): ?>
+ <?php if ($view['session']->getFlashBag()->has('notice')): ?>
<div class="flash-notice">
- <?php echo $view['session']->getFlashes()->get('notice') ?>
+ <?php echo $view['session']->getFlashBag()->get('notice') ?>
</div>
<?php endif; ?>
- 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:
- <?php foreach ($view['session']->getFlashes()->all() as $type => $flash): ?>
+ <?php foreach ($view['session']->getFlashBag()->all() as $type => $flash): ?>
<div class="flash-$type">
<?php echo $flash; ?>
</div>
@@ -48,17 +48,17 @@ public function get($name, $default = null)
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);
}
/**
@@ -51,7 +51,7 @@ public function setFlashAction($message)
{
$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 @@ public function showFlashAction()
$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.';
}
@@ -26,7 +26,7 @@ public function setUp()
$session = new Session(new MockArraySessionStorage());
$session->set('foobar', 'bar');
- $session->getFlashes()->set('notice', 'bar');
+ $session->getFlashBag()->set('notice', 'bar');
$this->request->setSession($session);
}
@@ -15,6 +15,7 @@
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 @@ public function toolbarAction($token, $position = null)
{
$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) {
@stof

stof Feb 11, 2012

Member

shouldn't it be $session->getFlashBag() instanceof AutoExpireFlashBag ?

+ // keep current flashes for one more request if using AutoExpireFlashBag
+ $session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if (null === $token) {
@@ -74,9 +74,7 @@ public function onKernelResponse(FilterResponseEvent $event)
$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'))));
@@ -241,7 +241,7 @@ public function getBag($name)
*
* @return FlashBagInterface
*/
- public function getFlashes()
+ public function getFlashBag()
{
return $this->getBag('flashes');
}

0 comments on commit 8a01dd5

Please sign in to comment.