The actual menu validation logic.

@param $package_name
@param $menu_data

@throws \Seat\Web\Exceptions\PackageMenuBuilderException
508277
public function validate_menu($package_name, $menu_data)
    {

        if (! is_string($package_name))
            throw new PackageMenuBuilderException(
                'Package root menu items should be named by string type');

        if (! is_array($menu_data))
            throw new PackageMenuBuilderException(
                'Package menu data should be defined in an array');

        // check if required keys are all sets
        foreach ($this->getRequiredKeys() as $key)
            if (! array_key_exists($key, $menu_data))
                throw new PackageMenuBuilderException(
                    'Menu should contain a ' . $key . ' entry');

        // Check if we have sub entries. If not, we have to
        // check if we have a route defined in the parent
        // menu.
        if (! array_key_exists('entries', $menu_data))
            if (! array_key_exists('route', $menu_data))
                throw new PackageMenuBuilderException(
                    'A parent or sub-menu route is required.');

        // Ensure that the entries is actually an array
        if (array_key_exists('entries', $menu_data) && ! is_array($menu_data['entries']))
            throw new PackageMenuBuilderException(
                'Root menu must define entries');

        // Loop over the sub menu entries, validating the
        // required fields
        if (isset($menu_data['entries'])) {

            foreach ($menu_data['entries'] as $entry) {

                if (! array_key_exists('name', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a name');

                if (! array_key_exists('icon', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define an icon');

                if (! array_key_exists('route', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a route');

                if (isset($entry['entries'])) {

                    foreach ($entry['entries'] as $subentry) {

                        if (! array_key_exists('name', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a name');

                        if (! array_key_exists('icon', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define an icon');

                        if (! array_key_exists('route', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a route');

                    }

                }
            }
        }
    }
4128
public boolean hasMenuEntry(AdminComponent component, MenuEntry activeMenue) {
		if (null != component && null != component.getMainMenu()) {
			Optional<MenuEntry> result = component.getMainMenu().flattened()
					.filter(menu -> checkForNull(menu, activeMenue) ? menu.getName().equals(activeMenue.getName()): false)
					.findFirst();
			return result.isPresent();
		}
		return false;
	}
1048691
public boolean validatePackageNameType(String packageNameType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}
223666
public static function get_menu_name($theme_location)
    {
        $menu_obj = static::get_menu_object($theme_location);

        if ($menu_obj !== false) {
            return $menu_obj->name;
        }

        return false;
    }
250504
def addAboutMenu(menuName, parentMenuFunction=None):
    '''
    
    '''

    parentMenuFunction = parentMenuFunction or iface.addPluginToMenu
    namespace = _callerName().split(".")[0]
    icon = QtGui.QIcon(os.path.join(os.path.dirname(os.path.dirname(__file__)), "icons", "help.png"))
    aboutAction = QtWidgets.QAction(icon, "About...", iface.mainWindow())
    aboutAction.setObjectName(namespace + "about")
    aboutAction.triggered.connect(lambda: openAboutDialog(namespace))
    parentMenuFunction(menuName, aboutAction)
    global _aboutActions
    _aboutActions[menuName] = aboutAction
1298121
public void setMenu(Menu menu) {
        this.menu = menu;

        RadialMenuItem.setupMenuButton(this, radialMenuParams, (menu != null) ? menu.getGraphic() : null, (menu != null) ? menu.getText() : null, true);
    }
303111
private function isRelevant(PackageClass $package_class)
    {
        $class_name = $package_class->getName();
        if (strstr($class_name, '\\Generated\\')
            || $package_class->isInterface()
            || $package_class->isException()
            || strpos($class_name, $this->type) === false
        ) {
            return false;
        }
        return true;
    }
188813
public void setCategoriesAdapterFromMenu(@MenuRes int menuRes) {
        Menu menu = new MenuBuilder(getContext());
        new MenuInflater(getContext()).inflate(menuRes, menu);
        setCategoriesAdapterFromMenu(menu);
    }
1131558
function (menuId, menuItemId, menuItemTitle, menuItemUiState, menuItemType, position) {
            this.validateMenuExistance(menuId);

            // Push new menu item
            menus[menuId].items.push({
                id: menuItemId,
                title: menuItemTitle,
                uiState: menuItemUiState,
                class: menuItemType,
                position: position || 0,
                items: []
            });

            // Return the menu object
            return menus[menuId];
        }
150175
def raw_menu_data(menu, sub = false)
			if menu.is_a?(Integer)
				data =
					if sub 
						MenuOption.where(:parent_id => MenuOption.find(menu).option_id)
					else 
						MenuOption.where(:menu_id => menu, :parent_id => nil)
					end
			else
				m = Menu.find_by_key(menu)
				data =
					if sub 
						MenuOption.where(:parent_id => MenuOption.find(m[:id]).option_id)
					else 
						MenuOption.where(:menu_id => m[:id], :parent_id => nil)
					end
			end

			data

		end
418245
@Override public boolean onCreateOptionsMenu(Menu menu) {
    if (actionBarMenuAction != null) {
      menu.add(actionBarMenuAction.title)
          .setShowAsActionFlags(SHOW_AS_ACTION_ALWAYS)
          .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override public boolean onMenuItemClick(MenuItem menuItem) {
              actionBarMenuAction.action.call();
              return true;
            }
          });
    }
    menu.add("Log Scope Hierarchy")
        .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
          @Override public boolean onMenuItemClick(MenuItem item) {
            Log.d("DemoActivity", MortarScopeDevHelper.scopeHierarchyToString(activityScope));
            return true;
          }
        });
    return true;
  }
1102757
public static JMenuItem addMenuItem (
        ActionListener l, JMenu menu, String name, int mnem)
    {
        return addMenuItem(l, menu, name, Integer.valueOf(mnem), null);
    }
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;
            }
        }
    }
99211
protected function generateMenu($menuBuilder, $menu)
    {
        $subMenu = $this->registerMenu($menuBuilder, $menu);
        $menu->children->each(function (Menu $subItem) use ($subMenu) {
            $subMenuChild = $this->registerMenu($subMenu, $subItem);
            if (count($subItem->children)) {
                $this->generateMenu($subMenuChild, $subItem);
            }
        });
    }
648171
public function getPackageAssetsWebPath($package_name)
    {
        $package = $this->getPackage($package_name);
        return $this->buildWebPath($package->getAssetsPath());
    }
985677
public function attachMenuItemToForeignModule(
        string $foreignMenuLink,
        MenuItem $internalMenuItem,
        MenuItem $menuItem
    ) {
        $foreignMenuItem = $this->getMenuItemByLink($foreignMenuLink);
        if (!is_null($foreignMenuItem)) {
            $foreignMenuItem->addChild($menuItem);
        } else {
            $internalMenuItem->addChild($menuItem);
            $this->attachMenuItem($internalMenuItem);
        }
    }
868704
function(menu, data) {
        if (!data.children || !data.children.length) {
            return;
        }

        var options = this.options,
            groups = [],
            ul,
            li,
            tag,
            limit = options.itemLimit,
            i, l;

        if (options.className) {
            menu.addClass(options.className);
        }

        menu
            .aria('expanded', false)
            .attr('role', 'menu');

        if (limit && data.children.length > limit) {
            i = 0;
            l = data.children.length;

            while (i < l) {
                groups.push(data.children.slice(i, i += limit));
            }
        } else {
            groups.push(data.children);
        }

        for (var g = 0, group, child; group = groups[g]; g++) {
            ul = $('<ul/>');

            for (i = 0, l = group.length; i < l; i++) {
                child = group[i];

                // Build tag
                if (child.url) {
                    li = $('<li/>');
                    tag = $('<a/>', {
                        text: child.title,
                        href: child.url,
                        role: 'menuitem'
                    });

                    // Add icon
                    $('<span/>')
                        .addClass(child.icon || (Toolkit.isRTL ? 'caret-left' : 'caret-right'))
                        .prependTo(tag);

                } else {
                    li = this.render(options.template);
                    tag = $('<span/>', {
                        text: child.title,
                        role: 'presentation'
                    });
                }

                if (child.attributes) {
                    tag.attr(child.attributes);
                }

                // Build list
                if (child.className) {
                    li.addClass(child.className);
                }

                li.append(tag).appendTo(ul);

                if (child.children && child.children.length) {
                    var childMenu = this.render(options.template)
                        .conceal()
                        .appendTo(li);

                    this._buildMenu(childMenu, child);

                    li.addClass('has-children')
                        .aria('haspopup', true)
                        .on('mouseenter', this.onPositionChild.bind(this, li))
                        .on('mouseleave', this.onHideChild.bind(this, li));
                }
            }

            menu.append(ul);
        }

        // Only monitor top level menu
        if (options.mode !== 'click' && menu.hasClass('is-root')) {
            menu.on({
                mouseenter: function() {
                    this.clearTimer('hide');
                }.bind(this),
                mouseleave: function() {
                    this.startTimer('hide', options.hideDelay);
                }.bind(this)
            });
        }
    }