From b92b61dd4559d6cd18bb3dae8cd6e968fab39772 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 2 Apr 2020 17:40:10 +0200 Subject: [PATCH] wip #3520 --- src/app/Magic/Menu/Item.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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 = ''; } -- 2.39.5