From 3d2cac534cdfa9b7856acae844adf612fd74f29c Mon Sep 17 00:00:00 2001 From: restyler <russiancss@gmail.com> Date: Mon, 18 Aug 2014 10:47:07 +0000 Subject: [PATCH] Multiple flash messages per type support --- framework/web/Session.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/framework/web/Session.php b/framework/web/Session.php index bccb0c1..95e1fdf 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -717,7 +717,13 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co { $counters = $this->get($this->flashParam, []); $counters[$key] = $removeAfterAccess ? -1 : 0; - $_SESSION[$key] = $value; + + if (!empty($_SESSION[$key])) { + $_SESSION[$key][] = $value; + } else { + $_SESSION[$key] = [$value]; + } + $_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. - * @param string $key key identifying the flash message - * @return boolean whether the specified flash message exists + * Returns a value indicating whether there are flash messages associated with the specified key. + * @param string $key key identifying the flash message type + * @return boolean whether any flash messages exist under specified key */ public function hasFlash($key) { -- libgit2 0.27.1