Get menu items

@param string $menu The menu to get items
@return string[] The menu items
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;
	}
1357424
public static function getMenuItems($key)
    {
        $menuItems = [];

        $storedMenuItems = Cache::remember('', 10, function () {
            return MenuItem::all();
        });

        foreach ($storedMenuItems as $menuItem) {
            $menuItems[$menuItem->{$key}] = $menuItem;
        }

        return $menuItems;
    }
819245
protected function _prepareItems($items)
    {
        if (is_integer($items)) {
            $id = $items;
            $cacheKey = "render({$id})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = TableRegistry::get('Menu.MenuLinks')
                    ->find('threaded')
                    ->where(['menu_id' => $id])
                    ->all();
                static::cache($cacheKey, $items);
            }
        } elseif (is_string($items)) {
            $slug = $items;
            $cacheKey = "render({$slug})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = [];
                $menu = TableRegistry::get('Menu.Menus')
                    ->find()
                    ->select(['id'])
                    ->where(['slug' => $slug])
                    ->first();

                if ($menu instanceof EntityInterface) {
                    $items = TableRegistry::get('Menu.MenuLinks')
                        ->find('threaded')
                        ->where(['menu_id' => $menu->id])
                        ->all();
                }
                static::cache($cacheKey, $items);
            }
        }

        return $items;
    }
251279
protected function getMenuMethods($plugin)
    {
        //Gets all methods from `$PLUGIN\View\Helper\MenuHelper`
        $methods = get_child_methods(sprintf('\%s\View\Helper\MenuHelper', $plugin));

        //Filters invalid name methods and returns
        return $methods ? array_values(preg_grep('/^(?!_).+$/', $methods)) : [];
    }
833273
public static function getCustomMenuItems($user)
    {
        $menuItems = [];

        if (array_key_exists('menu', config('laralum'))) {
            foreach (config('laralum.menu') as $custom_menu) {
                $pm = new self();
                $pm->name(ucfirst($custom_menu['title']));
                $pm->items = array_merge($pm->items, static::getPackageMenuItems($custom_menu, $user));

                if (count($pm->items) > 0) {
                    array_push($menuItems, $pm);
                }
            }
        }

        return $menuItems;
    }
422223
public function all(string $identifier = ''): array
    {
        // Check whether the menu identifier exists.
        if ($identifier && ! $this->exists($identifier)) {
            return [];
        }

        return $identifier ? $this->menus[$identifier] : $this->menus;
    }
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;
    }
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;
    }
368426
public function menu($menu = null, $options = array())
	{
		$menu = $menu ?: $this->getDefaultMenu();

		// If the given menu has not been created before, we will create the instances
		// here and cache it so we can return it next time very quickly. If there is
		// already a menu created by this name, we'll just return that instance.
		if (!isset($this->menus[$menu]))
		{
			$this->menus[$menu] = $this->createMenu($menu, $options);
		}

		return $this->menus[$menu];
	}
543981
public function getItemsByUser($userId)
    {
        if (empty($userId)) {
            return [];
        }

        $query = (new Query)->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_id' => (string) $userId]);

        $roles = [];
        foreach ($query->all($this->db) as $row) {
            $roles[$row['name']] = $this->populateItem($row);
        }
        return $roles;
    }
44689
public function extendWith(Menu $menu)
    {
        $menu->group(trans('core::sidebar.content'), function (Group $group) {
            $group->weight(10);

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

        return $menu;
    }
194826
public function getTagItems(string $tag): array
    {
        $tagName = $this->getTagKey($tag);
        return explode(',', $this->handler->get($tagName));
    }
288469
public function userMenu(?Tree $tree): array
    {
        return array_filter([
            $this->menuPendingChanges($tree),
            $this->menuMyPages($tree),
            $this->menuThemes(),
            $this->menuLanguages(),
            $this->menuLogin(),
            $this->menuLogout(),
        ]);
    }
70647
public function getItems()
    {
        foreach ($this->_items as $name => $item) {
            $this->getItem($name);
        }

        return $this->_items;
    }
1035633
protected function getMenuItem(EntityInterface $menu, array $item, int $order = 0): array
    {
        if (empty($item)) {
            return [];
        }

        $label = $item['label'];
        $icon = $item['icon'];
        $type = $item['type'];

        $children = !empty($item['children']) ? $item['children'] : [];

        if (!empty($children)) {
            $count = 0;
            foreach ($children as $key => $child) {
                $children[$key] = $this->getMenuItem($menu, $child, ++$count);
            }
        }

        if (static::TYPE_MODULE === $type) {
            $item = $this->getMenuItemsFromEvent($menu->get('name'), [$item['url']]);
            reset($item);
            $item = current($item);
        }

        if (!empty($children)) {
            $item['children'] = $children;
        }

        if (empty($item)) {
            return [];
        }

        if (static::TYPE_MODULE === $type) {
            $item['label'] = $label;
            $item['icon'] = $icon;
        }

        $item['order'] = $order;

        return $item;
    }
1352047
public function getItems()
    {
        $items = [];
        if (isset($this->cart->items) === true) {
            foreach ($this->cart->items as $item) {
                $items[$item->getHash()] = $item;
            }
        }

        return $items;
    }
1204085
public static function get_viewable_menu_items($member = null)
    {
        if (!$member && $member !== false) {
            $member = Security::getCurrentUser();
        }

        $viewableMenuItems = array();
        $allMenuItems = self::get_menu_items();
        if ($allMenuItems) {
            foreach ($allMenuItems as $code => $menuItem) {
                        // exclude all items which have a controller to perform permission
                        // checks on
                if ($menuItem->controller) {
                    $controllerObj = singleton($menuItem->controller);
                    if (Controller::has_curr()) {
                        // Necessary for canView() to have request data available,
                        // e.g. to check permissions against LeftAndMain->currentPage()
                        $controllerObj->setRequest(Controller::curr()->getRequest());
                        if (!$controllerObj->canView($member)) {
                            continue;
                        }
                    }
                }

                $viewableMenuItems[$code] = $menuItem;
            }
        }

        return $viewableMenuItems;
    }