Frozennode\Administrator\Menu::getMenu PHP Méthode

getMenu() public méthode

Gets the menu items indexed by their name with a value of the title.
public getMenu ( array $subMenu = null ) : array
$subMenu array (used for recursion)
Résultat array
    public function getMenu($subMenu = null)
    {
        $menu = array();
        if (!$subMenu) {
            $subMenu = $this->config->get('administrator.menu');
        }
        //iterate over the menu to build the return array of valid menu items
        foreach ($subMenu as $key => $item) {
            //if the item is a string, find its config
            if (is_string($item)) {
                //fetch the appropriate config file
                $config = $this->configFactory->make($item);
                //if a config object was returned and if the permission passes, add the item to the menu
                if (is_a($config, 'Frozennode\\Administrator\\Config\\Config') && $config->getOption('permission')) {
                    $menu[$item] = $config->getOption('title');
                } elseif ($config === true) {
                    $menu[$item] = $key;
                }
            } elseif (is_array($item)) {
                $menu[$key] = $this->getMenu($item);
                //if the submenu is empty, unset it
                if (empty($menu[$key])) {
                    unset($menu[$key]);
                }
            }
        }
        return $menu;
    }