Get menu links of a particular menu.

@param  string $menuSlug
@return array|\Illuminate\Support\Collection|mixed
@throws \Exception
433775
public static function getMenuLinks($menuSlug)
    {
        // Set active MenuLinks
        MenuLink::setActiveIDs(true);

        $menuData = self::findBySlug($menuSlug);
        $menuLinks = MenuLink::where('menuID', $menuData->menuID)->orderBy('order')->get();

        if($menuLinks) {
            return MenuLink::children($menuLinks);
        }
    }
986249
public function getLinkTypes()
    {
        $event = new Event('Wasabi.Backend.MenuItems.getLinkTypes', $this);
        EventManager::instance()->dispatch($event);

        $typeExternal = ['type' => 'external'];
        $typeCustom = ['type' => 'custom'];

        $event->result[__d('wasabi_core', 'General')] = [
            json_encode($typeExternal) => __d('wasabi_core', 'External Link'),
            json_encode($typeCustom) => __d('wasabi_core', 'Custom Controller Action')
        ];

        return $event->result;
    }
963348
public function menuPanelItems($lang = "")
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('PostType', 'read')) {
            return $this->noPermission();
        }

        // Find post types
        if(Input::input('keyword')) {
            $postTypes = PostType::where('name', 'like', '%test%')->paginate(PostType::$rowsPerPage);
        }else{
            $postTypes = PostType::where("slug", '!=', "post_pages")->paginate(PostType::$rowsPerPage);
        }

        // Append extra attributes
        foreach($postTypes->all() as $postType){
            $postType->belongsTo = 'post_type';
            $postType->belongsToID = $postType->postTypeID;
            $postType->label = $postType->name;
            $postType->menuLinkParameters = $postType->menuLinkParameters();
        }

        // Append columns
        $results = $postTypes->toArray();
        $results['columns'] = [
            'postTypeID' => trans('id'),
            'name' => trans('base.title'),
        ];

        return $results;
    }
528882
public function getBreadcrumbs(): array
    {
        if (empty($this->stack)) {
            $this->getRootItem($this->getCurrent());
            $this->stack = array_reverse($this->stack);
            $this->stack = array_map(
                function (ItemInterface $item) {
                    return $this->used[ItemHelper::getIdentifier($item)];
                },
                $this->stack
            );
        }

        return $this->stack;
    }
1049404
protected function fetchAliasRouteNames()
    {
        if ('_list' != substr($this->getRouteName(), -5))
        {
            throw new MenuException('Route name used for AdminGeneratorMenuItems must end with _list');
        }
        
        $baseName = substr($this->getRouteName(), 0, -4);
        $actions = array('edit', 'update', 'show', 'object', 'batch', 'new', 'create', 'filters', 'scopes');
        
        $routes = array();
        foreach ($actions as $action)
        {
            $routes[] = $baseName.$action;
        }
        
        $this->addAliasRoutes($routes);
        
        return parent::fetchAliasRouteNames();
    }
568055
public function getBySlug($slug)
    {
        if (! isset($this->entitiesBySlug[$slug])) {
            throw new DomainErrorException('Unable to find entity for slug '.$slug.'!');
        }

        return $this->entitiesBySlug[$slug];
    }
941976
public function getMenuItem($key)
    {
        list($menu, $item) = explode('.', $key);

        $menu = $this->menu_collection->get($menu);

        if (is_null($menu)) {
            throw new \Exception('Menu can not be found.');
        }

        $item = $menu->get($item);

        if (is_null($item)) {
            throw new \Exception('Item can not be found.');
        }

        return $item;
    }
666720
public function getBySlug($slug)
    {
        if (empty($slug))
            throw new Exception("Cannot retrieve object [".get_class($this->getModel())."] without slug");

        $results = $this->multiGetBySlug((array)$slug);
        if (isset($results[$slug]))
            return $results[$slug];

        throw new Exception(get_class($this->getModel()).' not found for slug: '.$slug);

    }
269885
private function plugin_action_links( $links ) {
		$link = $this->get_view( 'admin/include/action_links', [
			'url' => menu_page_url( $this->get_menu_slug(), false ),
		] );
		array_unshift( $links, $link );

		return $links;
	}
503883
protected function getSelectedCategory($categorySlug = null)
    {
        $selectedCategory = null;

        if ($categorySlug !== null) {
            $selectedCategory = $this->getCategoryRepository()->findOneBy(array('isActive' => true, 'slug' => $categorySlug));
        }

        return $selectedCategory;
    }
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;
    }
639066
protected function parseMenu($menus)
    {
        $menuItems = array();
        foreach ($menus as $name => $config) {
            if (!array_key_exists('route', $config) && !array_key_exists('uri', $config)) {
                throw new RuntimeException('"route" key must be set.');
            }

            $route = array_key_exists('route', $config) ? $config['route'] : $config['uri'];

            $menuItems[$route] = array();
            if (array_key_exists('child', $config)) {
                $menuItems[$route]['child'] = $this->parseMenu($config['child']);
            }

            $menuItems[$route]['label'] = $name;
            $menuItems[$route]['role'] = array_key_exists('role', $config) ? $config['role'] : 'ROLE_USER';
            $menuItems[$route]['icon'] = array_key_exists('icon', $config) ? $config['icon'] : 'fa-bars';
            $menuItems[$route]['extra'] = array_key_exists('extra', $config) ? $config['extra'] : '';
        }

        return $menuItems;
    }
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;
    }
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;
    }
400723
public function getMenu($key)
    {
        if (is_array($key)) {
            $menu_items = $key;
        } else {
            $menu_items = explode(',', $key);
        }

        // Comma-deliminated string requested.
        if (count($menu_items) > 1 || is_array($key)) {
            $result = collect();

            foreach ($menu_items as $key) {
                $menu = $this->menu_collection->get($key);

                if (is_null($menu)) {
                    continue;
                }

                foreach ($menu->all() as $item) {
                    $result->push($item);
                }
            }

            // Create new menu and return.
            return new Menu($key, $result);
        }

        return $this->menu_collection->get($key);
    }
1344361
public static function parentID($menuLinkID)
    {
        $parentIDs = [];
        while($menuLinkID != null){
            $parentObj = MenuLink::all()->where('menuLinkID', $menuLinkID)->first();
            if ($parentObj) {
                $menuLinkID = $parentObj->parent;
                if ($menuLinkID) {
                    $parentIDs[] = $menuLinkID;
                }
            }
            if ($parentObj || !$menuLinkID) {
                $menuLinkID = null;
            }
        }
        return $parentIDs;
    }
1286602
protected function extractMenus($menus)
    {
        if ($menus instanceof Closure) {
            $menus = $menus($this);
        }

        if (!is_array($menus)) {
            throw new Exception('子菜单必须是数组或者匿名函数返回数组', 1);
        }

        foreach ($menus as $key => $menu) {
            $menus[$key] = $menu->toArray();

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

        return $menus;
    }