Skip to content

Commit

Permalink
ADD visible option on menu
Browse files Browse the repository at this point in the history
Now all menus create a property in config menu.json visible to be able to disable it by environment
  • Loading branch information
soanix authored Nov 2, 2023
1 parent 4a56309 commit dbd258f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Cavesman/Classes/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public static function addItem(array $item): void
];
if (isset($item['items']) && $item['items']) {
foreach ($item['items'] as $menu) {

if (!isset(self::$items[$name]['items'][$menu['name']])) {
self::$items[$name]['items'][$menu['name']] = $menu;
if (!Config::get('menu.' . $menu . '.items.' . $menu['name'] . '.visible', true)) {
continue;
}
} else {
self::$items[$name]['items'][$menu['name']]['childs'] = array_merge_recursive(self::$items[$name]['items'][$menu['name']]['childs'], $menu['childs']);
}
Expand All @@ -39,6 +43,9 @@ public static function addItem(array $item): void
if (isset($itm['items']) && $itm['items']) {
foreach ($itm['items'] as $menu) {
if (!isset(self::$items[$name]['items'][$menu['name']])) {
if (!Config::get('menu.' . $name . '.items.' . $menu['name'] . '.visible', true)) {
continue;
}
self::$items[$name]['items'][$menu['name']] = $menu;
} else {
self::$items[$name]['items'][$menu['name']]['childs'] = array_merge_recursive(self::$items[$name]['items'][$menu['name']]['childs'], $menu['childs']);
Expand Down

0 comments on commit dbd258f

Please sign in to comment.