From: Vincent Vanwaelscappel Date: Thu, 2 Apr 2020 15:40:10 +0000 (+0200) Subject: wip #3520 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b92b61dd4559d6cd18bb3dae8cd6e968fab39772;p=cubist_cms-back.git wip #3520 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index 1bbde85..58f8d47 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -50,6 +50,11 @@ class Item protected $_href = ''; + /** + * @var string + */ + protected $_canonical = ''; + /** * @var array */ @@ -428,10 +433,37 @@ class Item $this->_href = $href; } + /** + * @return string + */ + public function getCanonical(): string + { + return $this->_canonical; + } + + /** + * @param string $canonical + */ + public function setCanonical(string $canonical): void + { + $this->_canonical = $canonical; + } + + public function getCanonicalURL(): string + { + $canonical = $this->getCanonical() || $this->getHref(); + return $this->_getURL($canonical); + } + public function getURL() + { + return $this->_getURL($this->getHref()); + } + + protected function _getURL($href) { $domain = Locale::getMainDomain($this->getLocale(), $this->getVariant()); - $href = $this->getHref(); + if ($href === 'home') { $href = ''; }