Builds a single menu item

@param string $menuName
@param string $subMenuName
@param string $url
@param int $order
@param bool|string $tooltip Tooltip to display.
167086
private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false)
    {
        if (!isset($this->menu[$menuName])) {
            $this->menu[$menuName] = array(
                '_hasSubmenu' => false,
                '_order' => $order
            );
        }

        if (empty($subMenuName)) {
            $this->menu[$menuName]['_url']   = $url;
            $this->menu[$menuName]['_order'] = $order;
            $this->menu[$menuName]['_name']  = $menuName;
            $this->menu[$menuName]['_tooltip'] = $tooltip;
            if (!empty($this->menuIcons[$menuName])) {
                $this->menu[$menuName]['_icon'] = $this->menuIcons[$menuName];
            } else {
                $this->menu[$menuName]['_icon'] = '';
            }
        }
        if (!empty($subMenuName)) {
            $this->menu[$menuName][$subMenuName]['_url'] = $url;
            $this->menu[$menuName][$subMenuName]['_order'] = $order;
            $this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
            $this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
            $this->menu[$menuName][$subMenuName]['_icon'] = $icon;
            $this->menu[$menuName][$subMenuName]['_onclick'] = $onclick;
            $this->menu[$menuName]['_hasSubmenu'] = true;

            if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
                $this->menu[$menuName]['_tooltip'] = $tooltip;
            }
        }
    }
128209
public function menu($attachTo=NULL, $params=NULL) {
		return $this->addComponent(new Menu($this->js), $attachTo, $params);
	}
925694
private function parseMenuItems($title, string $url, array $children, array $fields): Item
    {
        $urlGenerator = $this->instantiateUrlGenerator();

        // Extract parameters into variables
        if (is_array($title)) {
            extract($title);
        }

        // If child elements provided
        if ($children) {
            $childItems = [];

            foreach ($children as $child) {
                $this->checkFormat($child);

                // If child contains child elements, use recursively add them
                if (isset($child['children']) && $child['children']) {
                    $childItems[] = $this->parseMenuItems($child['title'], $child['url'], $child['children'],
                        $child['fields'] ?? []);
                } else {
                    $childItems[] = new Item($child['title'], $child['url'], [], $child['fields'] ?? [], new Config, $urlGenerator);
                }
            }
        }

        return new Item($title, $url, $childItems ?? $children, $fields, new Config, $urlGenerator);
    }
1325620
public function addMenuItem(MenuEvent $e)
    {
        $array = $e->getMenuConfig();

        $this->menu->addChild(
            $this->factory->createItem($array['name'], $array)
        );
    }
432220
public function upAction($pageId, $menuName)
    {
        $pageMenuRepo = $this->getDoctrine()->getRepository('FulgurioLightCMSBundle:PageMenu');
        $pageMenu = $pageMenuRepo->findOneBy(array('page' => $pageId, 'label' => $menuName));
        $position = $pageMenu->getPosition();
        if ($position > 1)
        {
            $pageMenuRepo->downMenuPagesPosition($menuName, $position - 1, $position);
            $pageMenu->setPosition($position - 1);
            $em = $this->getDoctrine()->getManager();
            $em->persist($pageMenu);
            $em->flush();
            $this->get('session')->getFlashBag()->add(
                    'notice',
                    $this->get('translator')->trans('fulgurio.lightcms.menus.moving_success_msg', array(), 'admin'));
        }
        return $this->redirect($this->generateUrl('AdminMenus'));
    }
692031
function override_submenu_action( $parent_slug, $menu_slug, $function ) {
			global $submenu;

			$menu_slug   = plugin_basename( $menu_slug );
			$parent_slug = plugin_basename( $parent_slug );

			if ( ! isset( $submenu[ $parent_slug ] ) ) {
				// Parent menu not exist.
				return false;
			}

			$found_submenu_item = false;
			foreach ( $submenu[ $parent_slug ] as $submenu_item ) {
				if ( $menu_slug === $submenu_item[2] ) {
					$found_submenu_item = $submenu_item;
					break;
				}
			}

			if ( false === $found_submenu_item ) {
				// Submenu item not found.
				return false;
			}

			// Remove current function.
			$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
			remove_all_actions( $hookname );

			// Attach new action.
			add_action( $hookname, $function );

			return $hookname;
		}
101189
public function addSystemItem($menuName, $url, $order = 50, $tooltip = false)
    {
        $this->addItem('CoreAdminHome_MenuSystem', $menuName, $url, $order, $tooltip);
    }
545663
function attachMenu(item) {
        var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu";
        item.contextMenu({
                menu:menuType
            },
            function (action, el, pos) {
                switch (action) {
                    case ADD_SUBFOLDER_MENU_COMMAND:
                        var parentFolderId = el.find('a').attr('id');
                        addFolder(parentFolderId);
                        break;
                    case DOWNLOAD_MENU_COMMAND:
                        download(el.find('a').attr('id'));
                        break;
                    case RENAME_MENU_COMMAND:
                        rename(el.find('a').attr('id'), true);
                        break;
                    case DELETE_MENU_COMMAND:
                        var link = el.find('a');
                        remove(link.attr('id'), link.hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "");
                        break;
                    default:
                        alert("Todo: apply action '" + action + "' to node " + el);
                }
            });

    }
878101
public function createItem($itemRouteName, array $itemOptions)
    {
        if (isset($itemOptions['item_class']))
        {
            $class = $itemOptions['item_class'];
        }
        else
        {
            $class = $this->getDefaultItemClass();
        }

        if (isset($this->itemClassAliases[$class]))
        {
            $class = $this->itemClassAliases[$class];
        }

        if (!$this->isValidMenuItemClass($class))
        {
            throw new NoMenuItemClassException(sprintf('Item class %s does not extend \C33s\MenuBundle\Item\MenuItem', $itemOptions['item_class']));
        }

        $item = new $class($itemRouteName, $itemOptions, $this);

        return $item;
    }
1363493
def add_to_submenu(self, submenu_path, item):
        '''
        
        '''
        for m in self.items:
            if m.name == submenu_path[0]:
                m.add_to_submenu(submenu_path[1:], item)
                return
        raise(ValueError("No submenu (%s) found" % (submenu_path[0])))
1164706
public static SubMenuItem asSubMenu(MenuItem item) {
        return visitWithResult(item, new AbstractMenuItemVisitor<SubMenuItem>() {
            @Override
            public void visit(SubMenuItem item) {
                setResult(item);
            }

            @Override
            public void anyItem(MenuItem item) { /* ignored */ }
        }).orElse(null);
    }
94709
public static function addAdminMenuItem($menuContent)
    {
        $menuPath = resource_path('views/admin/menu.blade.php');
        $menus = file_get_contents($menuPath);
        if (!str_contains($menus, $menuContent)) {
            file_put_contents($menuPath, $menus . "\n" . $menuContent . "\n");
        }
    }
1341664
public void addSubItem(WebMenuItem item){
		if (subMenu == null){
			subMenu = new ArrayList<WebMenuItem>();
		}
		subMenu.add(item);
	}
48255
private function order_sub_submenu_items() {
            global $submenu;

            $menu_slug = $this->_menu->get_top_level_menu_slug();

            /**
             * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
             * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
             * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
             * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
             *
             * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
             * of another plugin, only users that have the right role can access its sub-submenus since we will use the
             * capability needed to access the parent menu as the capability for the submenus that we will add.
             */
            if ( empty( $submenu[ $menu_slug ] ) ) {
                return;
            }

            $top_level_menu = &$submenu[ $menu_slug ];

            $all_submenu_items_after = array();

            $found_submenu_item = false;

            foreach ( $top_level_menu as $submenu_id => $meta ) {
                if ( $found_submenu_item ) {
                    // Remove all submenu items after the plugin's submenu item.
                    $all_submenu_items_after[] = $meta;
                    unset( $top_level_menu[ $submenu_id ] );
                }

                if ( $this->_menu->get_raw_slug() === $meta[2] ) {
                    // Found the submenu item, put all below.
                    $found_submenu_item = true;
                    continue;
                }
            }

            // Embed all plugin's new submenu items.
            $this->embed_submenu_items();

            // Start with specially high number to make sure it's appended.
            $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
            foreach ( $all_submenu_items_after as $meta ) {
                $top_level_menu[ $i ] = $meta;
                $i ++;
            }

            // Sort submenu items.
            ksort( $top_level_menu );
        }
12294
private function buildSubjectItem($menu, $item)
    {
        if (! empty($item->subject_type) && ! is_null($item->subject)) {
            return $menu->add($item->name, ['url' => $item->subject->getRouteForMenuItem()]);
        }

        return false;
    }
908270
public function buildMenus()
    {
        $menu = Menu::whereIsRoot()->get();
        foreach ($menu as $item) {
            LavaryMenu::make(Str::slug($item->name), function ($menu) use ($item) {
                $this->buildMenuItems($menu, $item);
            });
        }
    }
296611
private function addMenuItems(Item $parent, array $menu): void
	{
		foreach ($menu as $name => $item) {

			if (array_key_exists('link', $item)) {
				$link = $parent->addLink($name, $item['link'], isset($item['arguments']) ? $item['arguments'] : []);
				if (!empty($item['toBlank'])) {
					$link->toBlank();
				}
				if (!empty($item['count'])) {
					$this->setCount($link, $item['count']);
				}
				unset($item['link'], $item['arguments'], $item['toBlank'], $item['count']);
			} else {
				$link = $parent->addGroup($name);
			}
			$this->addMenuItems($link, $item);
		}
	}