From: Vincent Vanwaelscappel Date: Mon, 16 Sep 2019 16:38:52 +0000 (+0200) Subject: fix #3047 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4b0f8e2718b1ba08765c6f7fca64dedecf4194ae;p=cubist_cms-back.git fix #3047 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index 92b6009..8bc23ee 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -68,6 +68,11 @@ class Item */ protected $_menu_mobile_children = true; + /** + * @var bool + */ + protected $_robots = true; + /** * @var array @@ -536,6 +541,22 @@ class Item return $this->_menu_mobile; } + /** + * @param bool $robots + */ + public function setRobots(bool $robots): void + { + $this->_robots = $robots; + } + + /** + * @return bool + */ + public function isRobots(): bool + { + return $this->_robots; + } + /** * @return bool */ diff --git a/src/app/Magic/Menu/PageItem.php b/src/app/Magic/Menu/PageItem.php index ad04716..778c33f 100644 --- a/src/app/Magic/Menu/PageItem.php +++ b/src/app/Magic/Menu/PageItem.php @@ -25,12 +25,14 @@ class PageItem extends Item * @param $page CubistMagicPageModel * @param $all CubistMagicPageModel[] */ - public function initFromPage($page, $all) + public function initFromPage($page, $all = null) { $this->initFromEntity($page); $this->setPage($page); - $this->setChildrenFromData($all, $this->getId()); - $this->setChildrenFromTemplate(); + if (null !== $all) { + $this->setChildrenFromData($all, $this->getId()); + $this->setChildrenFromTemplate(); + } } /** @@ -38,11 +40,13 @@ class PageItem extends Item */ public function initFromEntity($entity) { + $data=$entity->getPageData(); $this->setId($entity->id); $this->setName($entity->name ?? get_class($entity) . '_' . $entity->id); $this->setSlug($entity->slug); $this->setTitle($entity->title); + $this->setRobots($data->get('robots',true)); $desktop = $entity->menu_desktop == '' ? 'children' : $entity->menu_desktop; diff --git a/src/app/Magic/Menu/VirtualItem.php b/src/app/Magic/Menu/VirtualItem.php index 7096032..eaf312b 100644 --- a/src/app/Magic/Menu/VirtualItem.php +++ b/src/app/Magic/Menu/VirtualItem.php @@ -7,10 +7,15 @@ namespace Cubist\Backpack\app\Magic\Menu; class VirtualItem extends Item { protected $_href = '#'; - protected $_classes=['nav-virtual']; + protected $_classes = ['nav-virtual']; public function isNavigable() { return false; } + + public function isRobots(): bool + { + return false; + } }