Add method set/getByRef to Icinga\Web\Session\SessionNamespace

This commit is contained in:
Johannes Meyer 2014-09-17 09:45:07 +02:00
parent 80c42ce499
commit efab6c7827
1 changed files with 21 additions and 0 deletions

View File

@ -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
*