From 68b7a21728f2d4838564b19a64ba776fbba124d4 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 30 Mar 2020 15:05:49 +0200 Subject: [PATCH] wip #3520 @2 --- src/app/Magic/Menu/Menu.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/app/Magic/Menu/Menu.php b/src/app/Magic/Menu/Menu.php index 75325e3..903e397 100644 --- a/src/app/Magic/Menu/Menu.php +++ b/src/app/Magic/Menu/Menu.php @@ -170,16 +170,22 @@ class Menu extends BaseMenu public function makeStandardMenu($menu, $item) { foreach ($item->getChildren() as $child) { - if (!$child->isMenuDesktop()) { - continue; - } - $parent = $menu->add($child->getTitle(), $child->getHref())->attr('data-name', $child->getName()); - // Handle items with submenus - if ($child->isMenuDesktopChildren()) { - foreach ($child->getChildren() as $subitem) { - $parent->add($subitem->getTitle(), $subitem->getHref())->attr('data-name', $subitem->getName()); - } - } + $this->_addItem($menu, $child, 'isMenuDesktop'); + } + } + + protected function _addItem($menu, $item, $checkFunction) + { + $checkFunctionChildren = $checkFunction . 'Children'; + if (!$item->$checkFunction()) { + return; + } + $parent = $menu->add($item->getTitle(), $item->getHref())->attr('data-name', $item->getName()); + if (!$item->$checkFunctionChildren() || !$item->hasChildren()) { + return; + } + foreach ($item->getChildren() as $child) { + $this->_addItem($parent, $child, $checkFunction); } } -- 2.39.5