class Item
{
- /** @var Item */
- protected $_root;
-
/** @var Item */
protected $_parent;
$all = $class::whereVariant($this->getVariant())->orderBy('lft')->get();
$this->setId('#root');
- $this->setRoot($this);
$this->setBreadcrumbs(false);
$this->setName($id);
$this->setChildrenFromData($all, null);
if ($data->getUsedTemplate() instanceof Navigation) {
$child->setBreadcrumbs(false);
}
- $child->initFromPage($data, $all);
$this->addChild($child);
+ $child->initFromPage($data, $all);
}
/**
public function getCanonicalURL(): string
{
- $canonical = $this->getCanonical() || $this->getHref();
+ $canonical = $this->getCanonical() === '' ? $this->getHref() : $this->getCanonical();
return $this->_getURL($canonical);
}
public function setParent(Item $parent): void
{
$this->_parent = $parent;
- $root = $parent->getRoot();
- if ($root !== null) {
- $this->setRoot($root);
- }
}
/**
*/
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();
}
/**