]> _ Git - cubist_cms-back.git/commitdiff
fix #3047
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Sep 2019 16:38:52 +0000 (18:38 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Sep 2019 16:38:52 +0000 (18:38 +0200)
src/app/Magic/Menu/Item.php
src/app/Magic/Menu/PageItem.php
src/app/Magic/Menu/VirtualItem.php

index 92b6009b12fe7649164127b1174feff929d198e8..8bc23ee464f70da1f237333de018bbdcf5808d97 100644 (file)
@@ -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
      */
index ad04716d9291b0cbbfaa85f6b8746ca7b8069899..778c33f1a1cfeb2f2cd3a0897342051484e9db14 100644 (file)
@@ -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;
 
index 70960325e1df895ef9a97eedaf991cdada1be4d9..eaf312b12362cbbdd03c67af6ed564ed29600ce1 100644 (file)
@@ -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;
+    }
 }