From efab6c7827ebf2fb0fd8df1302d15462cf417d1f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Sep 2014 09:45:07 +0200 Subject: [PATCH] Add method set/getByRef to Icinga\Web\Session\SessionNamespace --- .../Icinga/Web/Session/SessionNamespace.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/library/Icinga/Web/Session/SessionNamespace.php b/library/Icinga/Web/Session/SessionNamespace.php index b7495683b..fec3c5dca 100644 --- a/library/Icinga/Web/Session/SessionNamespace.php +++ b/library/Icinga/Web/Session/SessionNamespace.php @@ -126,6 +126,17 @@ class SessionNamespace implements IteratorAggregate return $this; } + public function setByRef($key, &$value) + { + $this->values[$key] = $value; + + if (in_array($key, $this->removed)) { + unset($this->removed[array_search($key, $this->removed)]); + } + + return $this; + } + /** * Getter for session values * @@ -139,6 +150,16 @@ class SessionNamespace implements IteratorAggregate return isset($this->values[$key]) ? $this->values[$key] : $default; } + public function & getByRef($key, $default = null) + { + $value = $default; + if (isset($this->values[$key])) { + $value = & $this->values[$key]; + } + + return $value; + } + /** * Delete the given value from the session *