src/Menu/Menu.php
protected function generateItems($items)
    {
        foreach ($items as $id => &$values) {
            $values = $this->setDefaultValues($id, $values);

            if (!$this->checkAccess($values)) {
                unset($items[$id]);
                continue;
            }

            $values['title'] = $this->getTitle($id, $values['title']);

            $values['url'] = $this->generateUrl($values);

            if (isset($values['submenu'])) {
                $values['submenu'] = $this->generateItems($values['submenu']);
            }

            if ($this->isActiveUrl($values)) {
                $values['active'] = true;
                $this->currentId = $id;
            } elseif (isset ($values['submenu'])) {
                // Check if there is an active item in the submenu, if
                // so it'll mark the current item as active as well.
                foreach ($values['submenu'] as $subitem) {
                    if ($subitem['active']) {
                        $values['active'] = true;
                        break;
                    }
                }
            }

            if ($values['active']) {
                $values['class'] .= ' '.$this->activeClass;
            }

            if ($values['submenu']) {
                $values['class'] .= ' '.$this->dropDownClass;
            }

            $values['class'] = trim($values['class']);

            unset(
                $values['callback'], $values['logged'], $values['roles'], $values['secure'],
                $values['params'], $values['route'], $values['action'], $values['full_url'],
                $values['allows'], $values['check'], $values['denies'], $values['exact']
            );
        }

        return $items;
    }
protected function generateItems($items)
    {
        foreach ($items as $id => &$values) {
            $values = $this->setDefaultValues($id, $values);

            if (!$this->checkAccess($values)) {
                unset($items[$id]);
                continue;
            }

            $values['title'] = $this->getTitle($id, $values['title']);

            $values['url'] = $this->generateUrl($values);

            if (isset($values['submenu'])) {
                $values['submenu'] = $this->generateItems($values['submenu']);
            }

            if ($this->isActiveUrl($values)) {
                $values['active'] = true;
                $this->currentId = $id;
            } elseif (isset ($values['submenu'])) {
                // Check if there is an active item in the submenu, if
                // so it'll mark the current item as active as well.
                foreach ($values['submenu'] as $subitem) {
                    if ($subitem['active']) {
                        $values['active'] = true;
                        break;
                    }
                }
            }

            if ($values['active']) {
                $values['class'] .= ' '.$this->activeClass;
            }

            if ($values['submenu']) {
                $values['class'] .= ' '.$this->dropDownClass;
            }

            $values['class'] = trim($values['class']);

            unset(
                $values['callback'], $values['logged'], $values['roles'], $values['secure'],
                $values['params'], $values['route'], $values['action'], $values['full_url'],
                $values['allows'], $values['check'], $values['denies'], $values['exact']
            );
        }

        return $items;
    }
protected function generateItems ( $ items ) { foreach ( $ items as $ id => & $ values ) { $ values = $ this -> setDefaultValues ( $ id , $ values ) ; if ( ! $ this -> checkAccess ( $ values ) ) { unset ( $ items [ $ id ] ) ; continue ; } $ values [ 'title' ] = $ this -> getTitle ( $ id , $ values [ 'title' ] ) ; $ values [ 'url' ] = $ this -> generateUrl ( $ values ) ; if ( isset ( $ values [ 'submenu' ] ) ) { $ values [ 'submenu' ] = $ this -> generateItems ( $ values [ 'submenu' ] ) ; } if ( $ this -> isActiveUrl ( $ values ) ) { $ values [ 'active' ] = true ; $ this -> currentId = $ id ; } elseif ( isset ( $ values [ 'submenu' ] ) ) { // Check if there is an active item in the submenu, if // so it'll mark the current item as active as well. foreach ( $ values [ 'submenu' ] as $ subitem ) { if ( $ subitem [ 'active' ] ) { $ values [ 'active' ] = true ; break ; } } } if ( $ values [ 'active' ] ) { $ values [ 'class' ] .= ' ' . $ this -> activeClass ; } if ( $ values [ 'submenu' ] ) { $ values [ 'class' ] .= ' ' . $ this -> dropDownClass ; } $ values [ 'class' ] = trim ( $ values [ 'class' ] ) ; unset ( $ values [ 'callback' ] , $ values [ 'logged' ] , $ values [ 'roles' ] , $ values [ 'secure' ] , $ values [ 'params' ] , $ values [ 'route' ] , $ values [ 'action' ] , $ values [ 'full_url' ] , $ values [ 'allows' ] , $ values [ 'check' ] , $ values [ 'denies' ] , $ values [ 'exact' ] ) ; } return $ items ; }
Generate the items for a menu or sub-menu.

This method will called itself if an item has a 'submenu' key.

@param array $items
@return array
Generate the items for a menu or sub - menu .