]> _ Git - cubist_cms-back.git/commitdiff
#2878
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 18:32:32 +0000 (20:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 18:32:32 +0000 (20:32 +0200)
src/app/Magic/Menu/Item.php
src/app/Magic/Menu/PageItem.php

index db2e6afbcec57a63199366e4fe994a83c3a0aa45..d87a894514261da3c409b7fecc46298af2dd3c80 100644 (file)
@@ -4,6 +4,7 @@
 namespace Cubist\Backpack\app\Magic\Menu;
 
 use Cubist\Backpack\app\Magic\Models\CMSPage;
+use Illuminate\Support\Str;
 
 class Item
 {
@@ -47,6 +48,13 @@ class Item
      */
     protected $_type = '';
 
+
+    /**
+     * @var array
+     */
+    protected $_controller = [];
+
+
     /**
      * @param string $id
      */
@@ -172,7 +180,11 @@ class Item
      */
     public function getHref()
     {
-        return $this->_href;
+        $href = $this->_href;
+        if (!$href) {
+            return Str::slug($this->getTitle());
+        }
+        return $href;
     }
 
     /**
@@ -221,6 +233,22 @@ class Item
         $this->_classes = $classes;
     }
 
+    /**
+     * @return array
+     */
+    public function getController(): array
+    {
+        return $this->_controller;
+    }
+
+    /**
+     * @param array $controller
+     */
+    public function setController(array $controller): void
+    {
+        $this->_controller = $controller;
+    }
+
     /**
      * @param $menu Menu
      */
@@ -242,11 +270,6 @@ class Item
                         }
                     }
                 } else {
-
-//                        // Some submenus have a title element
-//                        if (isset($submenu_data['title'])) {
-//                            $wrapper->raw($submenu_data['title'])->attr(['class' => 'nav-submenu-title']);
-//                        }
                     $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']);
                     foreach ($child->getChildren() as $subitem) {
                         $wrapper->add($subitem->getTitle(), $subitem->getHref());
index c8081e74b12058a1fdba28f695b64775b7a4fa25..d835ea070a892463aa67da4b3a49b994faa378dd 100644 (file)
@@ -77,4 +77,12 @@ class PageItem extends Item
     {
         return $this->_page;
     }
+
+    /**
+     * @return array
+     */
+    public function getController(): array
+    {
+        return ['controller' => 'PageController', 'action' => 'index', 'params' => [$this->getSlug()]];
+    }
 }