From: Vincent Vanwaelscappel Date: Wed, 10 Jul 2019 18:32:32 +0000 (+0200) Subject: #2878 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=fa23bdb5e0f4a5b0a27f79713a748fa1402637aa;p=cubist_cms-back.git #2878 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index db2e6af..d87a894 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -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()); diff --git a/src/app/Magic/Menu/PageItem.php b/src/app/Magic/Menu/PageItem.php index c8081e7..d835ea0 100644 --- a/src/app/Magic/Menu/PageItem.php +++ b/src/app/Magic/Menu/PageItem.php @@ -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()]]; + } }