From 69f28a3b355aa3487712af9084c8c81459963bfe Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 2 Apr 2020 17:54:07 +0200 Subject: [PATCH] wip #3520 --- src/app/Magic/Menu/Item.php | 34 +++++++++++++++++++++++++++++++++- src/app/Template/Model.php | 10 ---------- 2 files changed, 33 insertions(+), 11 deletions(-) delete mode 100644 src/app/Template/Model.php diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index 69ccc8b..a70e566 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -48,6 +48,11 @@ class Item protected $_href = ''; + /** + * @var string + */ + protected $_canonical = ''; + /** * @var array */ @@ -420,10 +425,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 = ''; } diff --git a/src/app/Template/Model.php b/src/app/Template/Model.php deleted file mode 100644 index 132e36e..0000000 --- a/src/app/Template/Model.php +++ /dev/null @@ -1,10 +0,0 @@ -