Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a01dd5

Browse files
committed
renamed getFlashes() to getFlashBag() to avoid clashes
1 parent 282d3ae commit 8a01dd5

File tree

8 files changed

+19
-20
lines changed

8 files changed

+19
-20
lines changed

CHANGELOG-2.1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
231231
* Added `AutoExpireFlashBag` (default) to replicate Symfony 2.0.x auto expire behaviour of messages auto expiring
232232
after one page page load. Messages must be retrived by `get()` or `all()`.
233233
* Deprecated the following methods from the Session class: `close()`, `setFlash()`, `setFlashes()`
234-
`getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashes() instead which returns a `FlashBagInterface`.
234+
`getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashBag() instead which returns a `FlashBagInterface`.
235235
* `Session->clear()` now only clears session attributes as before it cleared flash messages and
236-
attributes. `Session->getFlashes()->all()` clears flashes now.
236+
attributes. `Session->getFlashBag()->all()` clears flashes now.
237237
* Added `Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage` base class for
238238
session storage drivers.
239239
* Added `Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface` interface

UPGRADE-2.1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ UPGRADE FROM 2.0 to 2.1
268268

269269
After (PHP):
270270

271-
<?php if ($view['session']->getFlashes()->has('notice')): ?>
271+
<?php if ($view['session']->getFlashBag()->has('notice')): ?>
272272
<div class="flash-notice">
273-
<?php echo $view['session']->getFlashes()->get('notice') ?>
273+
<?php echo $view['session']->getFlashBag()->get('notice') ?>
274274
</div>
275275
<?php endif; ?>
276276

277-
If you wanted to process all flash types you could also make use of the `getFlashes()->all()` API:
277+
If you wanted to process all flash types you could also make use of the `getFlashBag()->all()` API:
278278

279-
<?php foreach ($view['session']->getFlashes()->all() as $type => $flash): ?>
279+
<?php foreach ($view['session']->getFlashBag()->all() as $type => $flash): ?>
280280
<div class="flash-$type">
281281
<?php echo $flash; ?>
282282
</div>

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ public function get($name, $default = null)
4848

4949
public function getFlash($name, $default = null)
5050
{
51-
return $this->session->getFlashes()->get($name);
51+
return $this->session->getFlashBag()->get($name);
5252
}
5353

5454
public function getFlashes()
5555
{
56-
return $this->session->getFlashes()->all();
56+
return $this->session->getFlashBag()->all();
5757
}
5858

5959
public function hasFlash($name)
6060
{
61-
return $this->session->getFlashes()->has($name);
61+
return $this->session->getFlashBag()->has($name);
6262
}
6363

6464
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function setFlashAction($message)
5151
{
5252
$request = $this->container->get('request');
5353
$session = $request->getSession();
54-
$session->getFlashes()->set('notice', $message);
54+
$session->getFlashBag()->set('notice', $message);
5555

5656
return new RedirectResponse($this->container->get('router')->generate('session_showflash'));
5757
}
@@ -61,8 +61,8 @@ public function showFlashAction()
6161
$request = $this->container->get('request');
6262
$session = $request->getSession();
6363

64-
if ($session->getFlashes()->has('notice')) {
65-
$output = $session->getFlashes()->get('notice');
64+
if ($session->getFlashBag()->has('notice')) {
65+
$output = $session->getFlashBag()->get('notice');
6666
} else {
6767
$output = 'No flash was set.';
6868
}

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function setUp()
2626

2727
$session = new Session(new MockArraySessionStorage());
2828
$session->set('foobar', 'bar');
29-
$session->getFlashes()->set('notice', 'bar');
29+
$session->getFlashBag()->set('notice', 'bar');
3030

3131
$this->request->setSession($session);
3232
}

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\HttpFoundation\RedirectResponse;
1717
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
18+
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
1819

1920
/**
2021
* ProfilerController.
@@ -146,9 +147,9 @@ public function toolbarAction($token, $position = null)
146147
{
147148
$request = $this->container->get('request');
148149

149-
if (null !== $session = $request->getSession()) {
150-
// keep current flashes for one more request
151-
$session->setFlashes($session->getFlashes());
150+
if (null !== $session = $request->getSession() && $session instanceof AutoExpireFlashBag) {
151+
// keep current flashes for one more request if using AutoExpireFlashBag
152+
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
152153
}
153154

154155
if (null === $token) {

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7474
$session = $request->getSession();
7575
if ($session instanceof AutoExpireFlashBag) {
7676
// keep current flashes for one more request if using AutoExpireFlashBag
77-
foreach ($session->getFlashKeys() as $type) {
78-
$session->setFlashes($session->getFlashes($type));
79-
}
77+
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
8078
}
8179

8280
$response->setContent($this->templating->render('WebProfilerBundle:Profiler:toolbar_redirect.html.twig', array('location' => $response->headers->get('Location'))));

src/Symfony/Component/HttpFoundation/Session/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function getBag($name)
241241
*
242242
* @return FlashBagInterface
243243
*/
244-
public function getFlashes()
244+
public function getFlashBag()
245245
{
246246
return $this->getBag('flashes');
247247
}

0 commit comments

Comments
 (0)