diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index 8476e40ce..e00fad03c 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -463,6 +463,25 @@ class Url return $this; } + /** + * Shift a query parameter from this URL if it exists, otherwise $default + * + * @param string $param Parameter name + * @param mixed $default Default value in case $param does not exist + * + * @return mixed + */ + public function shift($param, $default = null) + { + if (isset($this->params[$param])) { + $ret = $this->params[$param]; + unset($this->params[$param]); + } else { + $ret = $default; + } + return $ret; + } + /** * Return a copy of this url without the parameter given *