src/Menu/Provider/GroupMenuProvider.php
public function get($name, array $options = [])
    {
        $group = $options['group'];

        $menuItem = $this->menuFactory->createItem($options['name']);

        if (empty($group['on_top']) || false === $group['on_top']) {
            foreach ($group['items'] as $item) {
                if ($this->canGenerateMenuItem($item, $group)) {
                    $menuItem->addChild($this->generateMenuItem($item, $group));
                }
            }

            if (false === $menuItem->hasChildren()) {
                $menuItem->setDisplay(false);
            } elseif (!empty($group['keep_open'])) {
                $menuItem->setAttribute('class', 'keep-open');
                $menuItem->setExtra('keep_open', $group['keep_open']);
            }
        } elseif (1 === \count($group['items'])) {
            if ($this->canGenerateMenuItem($group['items'][0], $group)) {
                $menuItem = $this->generateMenuItem($group['items'][0], $group);
                $menuItem->setExtra('on_top', $group['on_top']);
            } else {
                $menuItem->setDisplay(false);
            }
        }
        $menuItem->setLabel($group['label']);

        return $menuItem;
    }
public function get($name, array $options = [])
    {
        $group = $options['group'];

        $menuItem = $this->menuFactory->createItem($options['name']);

        if (empty($group['on_top']) || false === $group['on_top']) {
            foreach ($group['items'] as $item) {
                if ($this->canGenerateMenuItem($item, $group)) {
                    $menuItem->addChild($this->generateMenuItem($item, $group));
                }
            }

            if (false === $menuItem->hasChildren()) {
                $menuItem->setDisplay(false);
            } elseif (!empty($group['keep_open'])) {
                $menuItem->setAttribute('class', 'keep-open');
                $menuItem->setExtra('keep_open', $group['keep_open']);
            }
        } elseif (1 === \count($group['items'])) {
            if ($this->canGenerateMenuItem($group['items'][0], $group)) {
                $menuItem = $this->generateMenuItem($group['items'][0], $group);
                $menuItem->setExtra('on_top', $group['on_top']);
            } else {
                $menuItem->setDisplay(false);
            }
        }
        $menuItem->setLabel($group['label']);

        return $menuItem;
    }
public function get ( $ name , array $ options = [ ] ) { $ group = $ options [ 'group' ] ; $ menuItem = $ this -> menuFactory -> createItem ( $ options [ 'name' ] ) ; if ( empty ( $ group [ 'on_top' ] ) || false === $ group [ 'on_top' ] ) { foreach ( $ group [ 'items' ] as $ item ) { if ( $ this -> canGenerateMenuItem ( $ item , $ group ) ) { $ menuItem -> addChild ( $ this -> generateMenuItem ( $ item , $ group ) ) ; } } if ( false === $ menuItem -> hasChildren ( ) ) { $ menuItem -> setDisplay ( false ) ; } elseif ( ! empty ( $ group [ 'keep_open' ] ) ) { $ menuItem -> setAttribute ( 'class' , 'keep-open' ) ; $ menuItem -> setExtra ( 'keep_open' , $ group [ 'keep_open' ] ) ; } } elseif ( 1 === \ count ( $ group [ 'items' ] ) ) { if ( $ this -> canGenerateMenuItem ( $ group [ 'items' ] [ 0 ] , $ group ) ) { $ menuItem = $ this -> generateMenuItem ( $ group [ 'items' ] [ 0 ] , $ group ) ; $ menuItem -> setExtra ( 'on_top' , $ group [ 'on_top' ] ) ; } else { $ menuItem -> setDisplay ( false ) ; } } $ menuItem -> setLabel ( $ group [ 'label' ] ) ; return $ menuItem ; }
Retrieves the menu based on the group options.

@param string $name

@throws \InvalidArgumentException if the menu does not exists

@return \Knp\Menu\ItemInterface
Retrieves the menu based on the group options .