From: Vincent Vanwaelscappel Date: Wed, 15 Apr 2020 13:39:12 +0000 (+0200) Subject: wip #3593 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9c0a1b63c02d31d5feff4579a9c37b15b1b99d52;p=cubist_cms-back.git wip #3593 @0.5 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index a70e566..443831c 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -13,9 +13,6 @@ use Illuminate\Support\Str; class Item { - /** @var Item */ - protected $_root; - /** @var Item */ protected $_parent; @@ -135,7 +132,6 @@ class Item $all = $class::whereVariant($this->getVariant())->orderBy('lft')->get(); $this->setId('#root'); - $this->setRoot($this); $this->setBreadcrumbs(false); $this->setName($id); $this->setChildrenFromData($all, null); @@ -170,8 +166,8 @@ class Item if ($data->getUsedTemplate() instanceof Navigation) { $child->setBreadcrumbs(false); } - $child->initFromPage($data, $all); $this->addChild($child); + $child->initFromPage($data, $all); } /** @@ -443,7 +439,7 @@ class Item public function getCanonicalURL(): string { - $canonical = $this->getCanonical() || $this->getHref(); + $canonical = $this->getCanonical() === '' ? $this->getHref() : $this->getCanonical(); return $this->_getURL($canonical); } @@ -742,10 +738,6 @@ class Item public function setParent(Item $parent): void { $this->_parent = $parent; - $root = $parent->getRoot(); - if ($root !== null) { - $this->setRoot($root); - } } /** @@ -753,15 +745,10 @@ class Item */ public function getRoot() { - return $this->_root; - } - - /** - * @param Item $root - */ - public function setRoot(Item $root): void - { - $this->_root = $root; + if ($this->getParent() === null) { + return $this; + } + return $this->getParent()->getRoot(); } /**