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
1 changed files with 6 additions and 7 deletions

View File

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