@param array $menu

@return array
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;
    }
295217
public static function items($menu = 'sidebar', $items = null)
    {
        if (!is_string($menu)) {
            throw new \UnexpectedValueException('Menu id is not a string');
        }

        if (!empty($items)) {
            self::$_items[$menu] = $items;
        }

        if (!array_key_exists($menu, self::$_items)) {
            Log::error('Invalid menu: ' . $menu);
            return [];
        }

        return self::$_items[$menu];
    }
1237968
public function addToMenu(Menu $menu)
    {
        if($this->postTypeID) {
            $data = [
                'menuID' => $menu->menuID,
                'belongsToID' => $this->categoryID,
                'belongsTo' => 'category',
                'params' => $this->menuLinkParameters(),
                'routeName' => 'category.posts'
            ];

            foreach (Language::all() as $language) {
                $data['slug'][$language->slug] = $this->translate($language->slug)->slug;
                $data['label'][$language->slug] = $this->title;
            }

            factory(MenuLink::class)->create($data);
        }

        return $this;
    }
388607
public function setFullBaseUrl(array $menu = []): array
    {
        $menu = array_map(
            function ($v) {
                $url = Hash::get($v, 'url');
                $children = Hash::get($v, 'children');
                if ($url) {
                    $v['url'] = Router::url($url, true);
                }
                if (is_array($children)) {
                    $v['children'] = $this->setFullBaseUrl($children);
                }

                return $v;
            },
            $menu
        );

        return $menu;
    }
648189
public static function cmsMenuLinks($menuLinks = [])
    {
        $links = [];
        $count = 0;

        if($menuLinks) {
            foreach($menuLinks as $menuLink){
                if($menuLink->belongsTo == "post_type") {
                    $permission = User::hasAccess($menuLink->slug, "read");
                }elseif($menuLink->belongsTo == "category") {
                    $permission = User::hasAccess("Category", "read");
                }else{
                    $permission = User::hasAccess($menuLink->slug, "update");
                }

                $routeURL = self::getActionOfLink($menuLink);
                if($routeURL) {
                    $links[$count] = [
                        'label' => $menuLink->label,
                        'menuLinkID' => $menuLink->menuLinkID,
                        'link' => self::removeDomainFromLink($routeURL),
                        'icon' => '',
                        'access' => $permission,
                        'children' => self::cmsMenuLinks($menuLink->children),
                    ];
                    $count++;
                }
            }
        }
        if(!count($links)) {
            return [];
        }
        return $links;
    }
574035
public function getParentMenu(Menu $menu, MenuItem $childNode)
    {
        $itemIterator = new RecursiveItemIterator($menu->getIterator());
        $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $menuItem) {
            $parentId = $childNode->getParent()->getId();
            if ($menuItem->getName() != $parentId) {
                continue;
            }

            return $menuItem;
        }

        return false;
    }
154025
static function getMenu($users = [])
    {
        $menuTables = self::getAll();
        if ($users && $users['gid'] !== '99') {
            $roleAuths = CommonRoleModel::getInfo($users['gid']);
            $auths = isset($roleAuths['auths']) ? $roleAuths['auths'] : array();
            foreach ($menuTables as $key => $value) {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if(isset($val['items']) && $val['items']) {
                            foreach ($val['items'] as $ks => $v) {
                                if (isset($v['url']) && !in_array($ks, (array) $auths))  {   
                                    unset($menuTables[$key]['items'][$k]['items'][$ks]);
                                } 
                            }
                        }  else if (isset($val['url']) && !in_array($k, (array) $auths)) {   
                            unset($menuTables[$key]['items'][$k]);
                        } 
                    }
                } else {
                    unset($menuTables[$key]);
                }
            }
        }
        foreach ($menuTables as $key => $value) {
            if (isset($value['items']) && empty($value['items'])) {
                unset($menuTables[$key]);
            } else if (isset($value['items']) && !$value['items']) {
                unset($menuTables[$key]);
            } else {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if (isset($val['items']) && empty($val['items'])) {
                            unset($menuTables[$key]['items'][$k]);
                        } else if ((!isset($val['items']) || !$val['items']) && !isset($val['url'])) {
                            unset($menuTables[$key]['items'][$k]);
                        }
                    }
                }   
            }
        }
        foreach ($menuTables as $key => $value) {
            if ((isset($value['items']) && empty($value['items'])) || (!isset($value['items']) || !$value['items'])) {
                unset($menuTables[$key]);
            }
        }
        return $menuTables;
    }
119363
public static function getMenuNotAllowAll(): array
    {
        $setor = !empty($_SESSION['userlogin']) ? $_SESSION['userlogin']['setor'] : "0";
        $path = "public/dash/-menu.json";
        $pathSession = !empty($setor) ? "public/dash/{$setor}/-menu.json" : "";
        $file = [];

        //public base
        if (file_exists(PATH_HOME . $path))
            $file = self::addNotShow(PATH_HOME . $path, $file);

        //public session
        if (!empty($pathSession) && file_exists(PATH_HOME . $pathSession))
            $file = self::addNotShow(PATH_HOME . $pathSession, $file);

        //para cada biblioteca
        foreach (Helper::listFolder(PATH_HOME . VENDOR) as $lib) {
            $base = PATH_HOME . VENDOR . "{$lib}/";

            //lib base
            if (file_exists($base . $path))
                $file = self::addNotShow($base . $path, $file, $base);

            //lib session
            if (!empty($pathSession) && file_exists($base . $pathSession))
                $file = self::addNotShow($base . $pathSession, $file, $base);
        }

        return $file;
    }
701116
private static function setParams($menuLink)
    {
        $menuLinkParams = self::decodeParams($menuLink->params);
        $routeParams = Route::getRoutes()->getByName($menuLink->routeName)->parameterNames();
        $params = [];
        foreach($routeParams as $key){
            if(isset($menuLinkParams[$key])) {
                $params[$key] = $menuLinkParams[$key];
            }
        }
        return $params;
    }
481704
public function getMenuItems($menu) {
		if( !isset(self::$menusConf) ) {
			self::$menusConf = IniConfig::build('menus', true);
		}
		if( empty(self::$menusConf) || empty(self::$menusConf->$menu) ) {
			return array();
		}
		return self::$menusConf->$menu;
	}
609724
public function getChildren(MenuItem $parent = null)
    {
        if ($parent == null) {
            return $this->getTopChildren();
        }
        $result = [];
        foreach ($this->adaptors as $menuAdaptor) {
            $menuAdaptor->adaptChildren($this, $result, $parent, $this->getRequest());
        }

        return $result;
    }
251186
public function delete($menus = array())
    {
        $rst = $this->_request->post($this->_url . 'menu/delete', $menus);
        return $this->_client->rst($rst);
    }
1288653
public function getMenuItems(): array
    {
        usort($this->menuItems, function ($a, $b) {
            return $a->getOrder() > $b->getOrder();
        });

        return $this->menuItems;
    }
194394
protected function extractMenus(array $menus)
    {
        foreach ($menus as $key => $menu) {
            $menus[$key] = $menu->toArray();

            if ($menu->sub_button) {
                $menus[$key]['sub_button'] = $this->extractMenus($menu->sub_button);
            }
        }

        return $menus;
    }
112040
public function addMenu(Menu $menu)
    {
        $menu->setArticle($this);
        $this->menus[] = $menu;

        return $this;
    }
459407
public function setMenu(array $menu): void
	{
		$this->items = [];
		foreach ($menu as $namespace => $modules) {
			if (!empty($modules)) {
				$this->addMenu($modules, $namespace);
			}
		}
	}
68164
public function getFullMenu($menuName)
    {
        if (is_array($menuName)) {
            $menuName = reset($menuName);
        }

        if (array_key_exists($menuName, $this->menuIterators) && count($this->menuIterators[$menuName]) > 0) {
            return $this->menuIterators[$menuName];
        }

        /** @var $mainMenu Menu */
        $mainMenu = $this->menuManager->findOneBy(
            ['name' => $menuName, 'locale' => $this->request->getLocale()]
        );

        if (!$mainMenu) {
            return [];
        }

        $this->menuIterators[$menuName] = $this->menuManager->getChildrenByStatus(
            $mainMenu,
            false,
            null,
            'ASC',
            false,
            $this->viewStatus
        );

        return $this->menuIterators[$menuName];
    }