Menu: Defer construction of the Url object to Menu::getUrl()

Before, the Url object was constructed in Menu::setUrl() which lead to an exception when parsing a module's configuration.php from our CLI.

refs #9375
This commit is contained in:
Eric Lippmann 2015-08-10 14:02:19 +02:00
parent b0a75dd89b
commit 1363ea4370

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;
} }