From bfc54b7e32fc1e0bb9ddcc8dd0a3ea16bd0d4d6f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Wed, 16 Jul 2014 15:16:05 +0200 Subject: [PATCH] Fix array conversion of the Dashboard and its Components Do not omit the parameters when converting the dashboard components to an array. Add an array conversion to the UrlParams class. refs #6691 --- library/Icinga/Web/Url.php | 4 ++-- library/Icinga/Web/UrlParams.php | 5 +++++ library/Icinga/Web/Widget/Dashboard/Component.php | 5 ++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index f47c8b193..c9da962be 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -22,7 +22,7 @@ class Url /** * An array of all parameters stored in this Url * - * @var array + * @var UrlParams */ protected $params; @@ -335,7 +335,7 @@ class Url */ public function getParams() { - return $this->params; + return $this->params->asArray(); } /** diff --git a/library/Icinga/Web/UrlParams.php b/library/Icinga/Web/UrlParams.php index 830d1b76e..9a8b60929 100644 --- a/library/Icinga/Web/UrlParams.php +++ b/library/Icinga/Web/UrlParams.php @@ -310,6 +310,11 @@ class UrlParams } } + public function asArray() + { + return $this->params; + } + public function __toString() { $parts = array(); diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index c658d98c4..8bac34359 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -126,10 +126,9 @@ EOD; public function toArray() { $array = array('url' => $this->url->getPath()); - foreach ($this->url->getParams() as $key => $value) { - $array[$key] = $value; + foreach ($this->url->getParams() as $param) { + $array[$param[0]] = $param[1]; } - return $array; }