Creates a menu for the OA.

@param Menu $menu
548802
public function storeMenu (Menu $menu)
    {
        $this->client->send(
            new Request(
                'POST',
                "https://api.weixin.qq.com/cgi-bin/menu/create",
                [],
                json_encode($this->reduceMenu($menu))
            )
        );
    }
664663
public function extendWith(Menu $menu)
    {
        $menu->group(trans('dashboard::dashboard.name'), function (Group $group) {
            $group->weight(0);
            $group->hideHeading();

            $group->item(trans('dashboard::module.title'), function (Item $item) {
                $item->icon('fa fa-dashboard');
                $item->route('dashboard.index');
                $item->isActiveWhen(route('dashboard.index', null, false));
                $item->authorize(
                    $this->auth->hasAccess('dashboard.dashboard.index')
                );
            });
        });

        return $menu;
    }
1257628
public function menuMyPages(?Tree $tree): ?Menu
    {
        if ($tree instanceof Tree && Auth::id()) {
            return new Menu(I18N::translate('My pages'), '#', 'menu-mymenu', [], array_filter([
                $this->menuMyPage($tree),
                $this->menuMyIndividualRecord($tree),
                $this->menuMyPedigree($tree),
                $this->menuMyAccount(),
                $this->menuControlPanel($tree),
                $this->menuChangeBlocks($tree),
            ]));
        }

        return null;
    }
248979
private void createMenus(Collection<ActionRef> parents, Collection<ActionRef> actions)
    {
        for (final ActionRef action : actions)
        {
            final Featurable menu = createMenu(action);
            if (!action.getRefs().isEmpty())
            {
                generateSubMenu(actions, action, menu);
            }
            else if (action.hasCancel())
            {
                previous.put(action, parents);
                generateCancel(action, menu);
            }
        }
        for (final Featurable current : menus)
        {
            handler.add(current);
        }
    }
200793
public function create($menu) {
        $args = $this->getCreate()->parameters($menu instanceof ArrayAble ? $menu->toArray() : $menu)
            ->json();
        if ($args['errcode'] === 0) {
            return true;
        }
        throw new \Exception($args['errmsg']);
    }
860530
public function extendWith(Menu $menu)
    {
        $menu->group(trans('core::sidebar.workshop'), function (Group $group) {
            $group->weight(20);

            $group->item(trans('user::users.title.users'), function (Item $item) {
                $item->weight(0);
                $item->icon('fa fa-user');
                $item->route('backend::user.user.index');
                $item->authorize(
                    $this->auth->can('user::manage-user')
                );
            });

            $group->item(trans('user::roles.title.roles'), function (Item $item) {
                $item->weight(1);
                $item->icon('fa fa-users');
                $item->route('backend::user.role.index');
                $item->authorize(
                    $this->auth->can('user::manage-role')
                );
            });
        });

        return $menu;
    }
539250
public void create(Menu menu) {
        String url = WxEndpoint.get("url.menu.create");
        String json = JsonMapper.nonEmptyMapper().toJson(menu);
        logger.debug("create menu: {}", json);
        wxClient.post(url, json);
    }
787214
protected function _addMenu(ItemInterface $menu, array $options)
    {
        $this->_menus[$menu->getName()] = $menu;
        $this->_menuConfigurations->attach($menu, $options);
    }
1203011
public function newMenuItemAction(Menu $menu)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = new MenuItem();
        $entity->setMenu($menu);
        $form = $this->createMenuItemCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
471432
public function createFromMenuItem(MenuItem $menuItem)
    {
        if ($path = $menuItem->getPath()) {
            $uri = $this->request->getBaseUrl().$path;
        } elseif ($menuItem->getRedirectUrl()) {
            $uri = $menuItem->getRedirectUrl();
        } elseif ($menuItem->getInternalUrl()) {
            $uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
        } elseif ($contentRoute = $menuItem->getContentRoute()) {
            $route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
            $uri = $this->request->getBaseUrl().$route->getPath();
        } else {
            $uri = '#';
        }

        $options = [
            'uri' => $uri,
            'label' => $menuItem->getName(),
            'attributes' => [],
            'linkAttributes' => $menuItem->getLinkAttributes(),
            'childrenAttributes' => [],
            'labelAttributes' => [],
            'extras' => [],
            'display' => true,
            'displayChildren' => true,

        ];
        $item = $this->factory->createItem($menuItem->getId(), $options);

        if ($menuItem->isHidden()) {
            $item->setDisplay(false);
        }

        return $item;
    }
275927
public function listMenu(Tree $tree): ?Menu
    {
        if ($this->listIsEmpty($tree)) {
            return null;
        }
        
        return new Menu(
            $this->listTitle(),
            $this->listUrl($tree),
            $this->listMenuClass(),
            $this->listUrlAttributes()
        );
    }
589303
def create
      @menu = Menu.new(menu_params)

      respond_to do |format|

        if @menu.save
          format.html { redirect_to edit_admin_menu_path(@menu), notice: I18n.t("controllers.admin.menus.create.flash.success")}
        else
          format.html {
            @all_menus = Menu.all
            render action: "index"
          }
        end

      end
    end
341436
public function menuLinks($menu = [])
    {
        if (empty($menu)) {
            $menu = $this->menu();
        }

        $links = [];

        foreach ($menu as $item) {
            if (!empty($item['children'])) {
                $links = array_merge($links, $this->menuLinks($item['children']));
            } else {
                $links[] = Arr::only($item, ['title', 'uri', 'icon']);
            }
        }

        return $links;
    }
733360
public function submenu($header, $menu = null)
    {
        list($header, $menu) = $this->parseSubmenuArgs(func_get_args());

        $menu = $this->createSubmenuMenu($menu);
        $header = $this->createSubmenuHeader($header);

        return $this->add($menu->prependIf($header, $header));
    }
408549
protected function CreateMenuAdmin()
	{
		// Load Language file for Module Object
		$lang = LanguageFactory::GetLanguageCollection("AdminModules");
		
		// Create a Menu Item for GROUPS and MODULES. 
		// This menu have CP_ before GROUP NAME
		$itGroup = $this->GetAdminGroups();
		
		while ($itGroup->hasNext())
		{
			$srGroup = $itGroup->moveNext();
			$this->defaultXmlnukeDocument->addMenuGroup($lang->Value("GROUP_" . strtoupper($srGroup->getField("name"))), "CP_" . $srGroup->getField("name"));
			
			$arrModules = $this->GetAdminModules($srGroup->getField("name"));
			
			foreach ($arrModules as $key=>$value)
			{
				$url = $value[1];
				$name = $key;
				$icon = $value[0];

				if ($url != "")
				{
					$this->defaultXmlnukeDocument->addMenuItem(
						$url,
						$lang->Value("MODULE_TITLE_" . strtoupper($name)),
						$lang->Value("MODULE_ABSTRACT_" . strtoupper($name)),
						"CP_" . $srGroup->getField("name"),
						$icon);
				}
			}
		}

		return $lang;
	}
1280649
public function setMenu(DropDownMenu $menu)
    {
        if ($this->menu instanceof DropDownMenu) {
            Checkers::notice('A dropdown menu already exists. The old one will be delete.');
        }
        $this->menu = $menu;
        return $this;
    }
1335450
public function add($menuId)
    {
        $this->loadModel('Menu.Menus');
        $this->loadModel('Content.Contents');
        $menu = $this->Menus->get($menuId);
        $link = $this->Menus->MenuLinks->newEntity();
        $link->set([
            'activation' => 'auto',
            'status' => 1,
            'menu_id' => $menuId
        ]);
        $this->Menus->MenuLinks->addBehavior('Tree', [
            'scope' => ['menu_id' => $menu->id]
        ]);

        if ($this->request->data()) {
            $link = $this->Menus->MenuLinks->patchEntity($link, $this->request->data, [
                'fieldList' => [
                    'parent_id',
                    'title',
                    'url',
                    'description',
                    'target',
                    'expanded',
                    'active',
                    'activation',
                    'status'
                ]
            ]);

            if ($this->Menus->MenuLinks->save($link)) {
                $this->Menus->MenuLinks->recover();
                $this->Flash->success(__d('menu', 'Link successfully created!'));

                if (!empty($this->request->data['action_add'])) {
                    $this->redirect(['plugin' => 'Menu', 'controller' => 'links', 'action' => 'add', $menuId]);
                } elseif (!empty($this->request->data['action_menu'])) {
                    $this->redirect(['plugin' => 'Menu', 'controller' => 'links', 'action' => 'menu', $menuId]);
                }
            } else {
                $this->Flash->danger(__d('menu', 'Link could not be saved, please check your information'));
            }
        }

        $contentLinks = [];
        $contents = $this->Contents
            ->find()
            ->select(['id', 'slug', 'content_type_slug', 'title'])
            ->all();
        foreach ($contents as $content) {
            $contentLinks[stripLanguagePrefix($content->get('url'))] = __d('menu', '{0} [{1}]', [
                $content->title,
                $content->content_type_slug
            ]);
        }

        $parentsTree = $this->Menus->MenuLinks
            ->find('treeList', ['spacer' => '--'])
            ->map(function ($link) {
                if (strpos($link, '-') !== false) {
                    $link = str_replace_last('-', '- ', $link);
                }

                return $link;
            });

        $this->title(__d('menu', 'Create New Link'));
        $this->set(compact('menu', 'link', 'contentLinks', 'parentsTree'));
        $this->Breadcrumb
            ->push('/admin/menu/manage')
            ->push(__d('menu', 'Editing menu "{0}"', $menu->title), ['plugin' => 'Menu', 'controller' => 'manage', 'action' => 'edit', $menuId])
            ->push(__d('menu', 'Links'), ['plugin' => 'Menu', 'controller' => 'links', 'action' => 'menu', $menuId])
            ->push(__d('menu', 'Add new link'), '#');
    }