class Item
{
+ /** @var Item */
+ protected $_parent;
+
/** @var Item[] */
protected $_children = [];
if ($item->getRawLocale() === '') {
$item->setLocale($this->getLocale());
}
+ $item->setParent($this);
$this->_children[] = $item;
}
return $this->_robots;
}
- public function getTranslatedPage($locale)
+ /**
+ * @param $locale
+ * @param bool $strict
+ * @return $this|Item|null
+ */
+ public function getTranslatedPage($locale, $strict = true)
{
if ($this->getLocale() === $locale) {
return $this;
}
$res = Menu::getNavigation($locale)->findOneById($this->getId());
+ if (!$strict && null === $res && null !== $this->getParent()) {
+ return $this->getParent()->getTranslatedPage($locale, $strict);
+ }
return $res;
}
$this->setMenuDesktopChildren($val);
$this->setMenuMobileChildren($val);
}
+
+ /**
+ * @return Item
+ */
+ public function getParent()
+ {
+ return $this->_parent;
+ }
+
+ /**
+ * @param Item $parent
+ */
+ public function setParent(Item $parent): void
+ {
+ $this->_parent = $parent;
+ }
}