Multiple flash messages per type support

This commit is contained in:
restyler
2014-08-18 10:47:07 +00:00
committed by Qiang Xue
parent c0d771f744
commit 3d2cac534c

View File

@ -717,7 +717,13 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
{ {
$counters = $this->get($this->flashParam, []); $counters = $this->get($this->flashParam, []);
$counters[$key] = $removeAfterAccess ? -1 : 0; $counters[$key] = $removeAfterAccess ? -1 : 0;
$_SESSION[$key] = $value;
if (!empty($_SESSION[$key])) {
$_SESSION[$key][] = $value;
} else {
$_SESSION[$key] = [$value];
}
$_SESSION[$this->flashParam] = $counters; $_SESSION[$this->flashParam] = $counters;
} }
@ -760,9 +766,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
} }
/** /**
* Returns a value indicating whether there is a flash message associated with the specified key. * Returns a value indicating whether there are flash messages associated with the specified key.
* @param string $key key identifying the flash message * @param string $key key identifying the flash message type
* @return boolean whether the specified flash message exists * @return boolean whether any flash messages exist under specified key
*/ */
public function hasFlash($key) public function hasFlash($key)
{ {