]> _ Git - cubist_cms-back.git/commitdiff
wip #3520
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Apr 2020 15:40:10 +0000 (17:40 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Apr 2020 15:40:10 +0000 (17:40 +0200)
src/app/Magic/Menu/Item.php

index 1bbde857fb566e62943901606cf3709bc2c8893f..58f8d475862f25730e62eba14d57df6dbcb6fca0 100644 (file)
@@ -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 = '';
         }