Merge branch 'bugfix/icingacli-no-request-object-9375'

fixes #9375
This commit is contained in:
Eric Lippmann 2015-08-11 09:20:59 +02:00
commit 1495cf5d04
3 changed files with 22 additions and 25 deletions

View File

@ -173,8 +173,10 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
/** /**
* Add a new property or section * Add a new property or section
* *
* @param string $key The name of the new property or section * @param string $key The name of the new property or section
* @param mixed $value The value to set for the new property or section * @param mixed $value The value to set for the new property or section
*
* @throws ProgrammingError If the key is null
*/ */
public function offsetSet($key, $value) public function offsetSet($key, $value)
{ {
@ -254,7 +256,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
/** /**
* Merge the given data with this config * Merge the given data with this config
* *
* @param array|Config $data An array or a config * @param array|ConfigObject $data An array or a config
* *
* @return $this * @return $this
*/ */

View File

@ -43,7 +43,7 @@ class Menu implements RecursiveIterator
/** /**
* The url of this menu * The url of this menu
* *
* @var string * @var string|null
*/ */
protected $url; protected $url;
@ -404,21 +404,20 @@ class Menu implements RecursiveIterator
*/ */
public function setUrl($url) public function setUrl($url)
{ {
if ($url instanceof Url) { $this->url = $url;
$this->url = $url;
} else {
$this->url = Url::fromPath($url);
}
return $this; return $this;
} }
/** /**
* Return the url of this menu * Return the url of this menu
* *
* @return Url * @return Url|null
*/ */
public function getUrl() public function getUrl()
{ {
if ($this->url !== null && ! $this->url instanceof Url) {
$this->url = Url::fromPath($this->url);
}
return $this->url; return $this->url;
} }

View File

@ -20,7 +20,7 @@ class Dashlet extends UserWidget
/** /**
* The url of this Dashlet * The url of this Dashlet
* *
* @var \Icinga\Web\Url * @var Url|null
*/ */
private $url; private $url;
@ -74,16 +74,13 @@ EOD;
{ {
$this->title = $title; $this->title = $title;
$this->pane = $pane; $this->pane = $pane;
if ($url instanceof Url) { if (! $url) {
$this->url = $url;
} elseif ($url) {
$this->url = Url::fromPath($url);
} else {
throw new IcingaException( throw new IcingaException(
'Cannot create dashboard dashlet "%s" without valid URL', 'Cannot create dashboard dashlet "%s" without valid URL',
$title $title
); );
} }
$this->url = $url;
} }
/** /**
@ -107,10 +104,13 @@ EOD;
/** /**
* Retrieve the dashlets url * Retrieve the dashlets url
* *
* @return Url * @return Url|null
*/ */
public function getUrl() public function getUrl()
{ {
if ($this->url !== null && ! $this->url instanceof Url) {
$this->url = Url::fromPath($this->url);
}
return $this->url; return $this->url;
} }
@ -123,11 +123,7 @@ EOD;
*/ */
public function setUrl($url) public function setUrl($url)
{ {
if ($url instanceof Url) { $this->url = $url;
$this->url = $url;
} else {
$this->url = Url::fromPath($url);
}
return $this; return $this;
} }
@ -159,7 +155,7 @@ EOD;
public function toArray() public function toArray()
{ {
$array = array( $array = array(
'url' => $this->url->getRelativeUrl(), 'url' => $this->getUrl()->getRelativeUrl(),
'title' => $this->getTitle() 'title' => $this->getTitle()
); );
if ($this->getDisabled() === true) { if ($this->getDisabled() === true) {
@ -178,9 +174,9 @@ EOD;
} }
$view = $this->view(); $view = $this->view();
$url = clone($this->url); $url = $this->getUrl();
$url->setParam('view', 'compact'); $url->setParam('view', 'compact');
$iframeUrl = clone($url); $iframeUrl = clone $url;
$iframeUrl->setParam('isIframe'); $iframeUrl->setParam('isIframe');
$searchTokens = array( $searchTokens = array(