Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[HttpFoundation] Refactored BC Session class methods.

If code has not be refactored for the new API's then
you would still be using the API with one message per $name.
  • Loading branch information...
commit b0466e8bb44ff941b4c106d1189f2fd4456398be 1 parent 84c2e3c
Drak authored
Showing with 21 additions and 7 deletions.
  1. +21 −7 src/Symfony/Component/HttpFoundation/Session/Session.php
View
28 src/Symfony/Component/HttpFoundation/Session/Session.php
@@ -229,7 +229,16 @@ public function getFlashBag()
*/
public function getFlashes()
{
- return $this->getBag('flashes')->all();
+ $all = $this->getBag($this->flashName)->all();
+
+ $return = array();
+ if ($all) {
+ foreach ($all as $name => $array) {
+ $return[$name] = reset($array);
+ }
+ }
+
+ return $return;
}
/**
@@ -239,7 +248,9 @@ public function getFlashes()
*/
public function setFlashes($values)
{
- $this->getBag('flashes')->setAll($values);
+ foreach ($values as $name => $value) {
+ $this->getBag($this->flashName)->set($name, $value);
+ }
}
/**
@@ -252,7 +263,9 @@ public function setFlashes($values)
*/
public function getFlash($name, $default = null)
{
- return $this->getBag('flashes')->get($name, $default);
+ $return = $this->getBag($this->flashName)->get($name);
+
+ return empty($return) ? $default : reset($return);
}
/**
@@ -263,7 +276,7 @@ public function getFlash($name, $default = null)
*/
public function setFlash($name, $value)
{
- $this->getBag('flashes')->set($name, $value);
+ $this->getBag($this->flashName)->set($name, $value);
}
/**
@@ -275,7 +288,7 @@ public function setFlash($name, $value)
*/
public function hasFlash($name)
{
- return $this->getBag('flashes')->has($name);
+ return $this->getBag($this->flashName)->has($name);
}
/**
@@ -285,7 +298,7 @@ public function hasFlash($name)
*/
public function removeFlash($name)
{
- $this->getBag('flashes')->get($name);
+ $this->getBag($this->flashName)->get($name);
}
/**
@@ -295,6 +308,7 @@ public function removeFlash($name)
*/
public function clearFlashes()
{
- return $this->getBag('flashes')->clear();
+ return $this->getBag($this->flashName)->clear();
}
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.