src/Renderer/StringTemplateRenderer.php
protected function _renderMenu(ItemInterface $item, array $options)
    {
        if (!$item->hasChildren() ||
            $options['depth'] === 0 ||
            !$item->getDisplayChildren()
        ) {
            return '';
        }

        $templater = $this->templater();

        $newTemplates =
            (array)$item->getExtra('templates') +
            (array)$options['templates'];
        if ($newTemplates) {
            $templater->push();
            $templater->add($newTemplates);
        }
        $options['defaultTemplates'] = $templater->getConfig();
        unset($options['templates']);

        $templateVars =
            (array)$item->getExtra('templateVars') +
            (array)$options['templateVars'];
        if (empty($templateVars)) {
            $templateVars = null;
        }
        $options['defaultTemplateVars'] = $templateVars;
        unset($options['templateVars']);

        $rendered = (string)$templater->format('menu', [
            'attrs' => $this->_formatAttributes($item->getChildrenAttributes(), $item),
            'templateVars' => $templateVars,
            'items' => $this->_renderChildren($item, $options)
        ]);

        if ($newTemplates) {
            $templater->pop();
        }

        return $rendered;
    }
protected function _renderMenu(ItemInterface $item, array $options)
    {
        if (!$item->hasChildren() ||
            $options['depth'] === 0 ||
            !$item->getDisplayChildren()
        ) {
            return '';
        }

        $templater = $this->templater();

        $newTemplates =
            (array)$item->getExtra('templates') +
            (array)$options['templates'];
        if ($newTemplates) {
            $templater->push();
            $templater->add($newTemplates);
        }
        $options['defaultTemplates'] = $templater->getConfig();
        unset($options['templates']);

        $templateVars =
            (array)$item->getExtra('templateVars') +
            (array)$options['templateVars'];
        if (empty($templateVars)) {
            $templateVars = null;
        }
        $options['defaultTemplateVars'] = $templateVars;
        unset($options['templateVars']);

        $rendered = (string)$templater->format('menu', [
            'attrs' => $this->_formatAttributes($item->getChildrenAttributes(), $item),
            'templateVars' => $templateVars,
            'items' => $this->_renderChildren($item, $options)
        ]);

        if ($newTemplates) {
            $templater->pop();
        }

        return $rendered;
    }
protected function _renderMenu ( ItemInterface $ item , array $ options ) { if ( ! $ item -> hasChildren ( ) || $ options [ 'depth' ] === 0 || ! $ item -> getDisplayChildren ( ) ) { return '' ; } $ templater = $ this -> templater ( ) ; $ newTemplates = ( array ) $ item -> getExtra ( 'templates' ) + ( array ) $ options [ 'templates' ] ; if ( $ newTemplates ) { $ templater -> push ( ) ; $ templater -> add ( $ newTemplates ) ; } $ options [ 'defaultTemplates' ] = $ templater -> getConfig ( ) ; unset ( $ options [ 'templates' ] ) ; $ templateVars = ( array ) $ item -> getExtra ( 'templateVars' ) + ( array ) $ options [ 'templateVars' ] ; if ( empty ( $ templateVars ) ) { $ templateVars = null ; } $ options [ 'defaultTemplateVars' ] = $ templateVars ; unset ( $ options [ 'templateVars' ] ) ; $ rendered = ( string ) $ templater -> format ( 'menu' , [ 'attrs' => $ this -> _formatAttributes ( $ item -> getChildrenAttributes ( ) , $ item ) , 'templateVars' => $ templateVars , 'items' => $ this -> _renderChildren ( $ item , $ options ) ] ) ; if ( $ newTemplates ) { $ templater -> pop ( ) ; } return $ rendered ; }
Renders the root menu item.

@param ItemInterface $item The menu item to render.
@param array $options The rendering options.
@return string The rendered menu item.
Renders the root menu item .