Skip to content

Commit

Permalink
Add method set/getByRef to Icinga\Web\Session\SessionNamespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Meyer committed Sep 24, 2014
1 parent 80c42ce commit efab6c7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/Icinga/Web/Session/SessionNamespace.php
Expand Up @@ -126,6 +126,17 @@ public function set($key, $value)
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
*
Expand All @@ -139,6 +150,16 @@ public function get($key, $default = null)
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
*
Expand Down

0 comments on commit efab6c7

Please sign in to comment.