Bootstrap\View\Helper\BootstrapNavbarHelper::beginMenu PHP Method

beginMenu() public method

Start a new menu, 2 levels: If not in submenu, create a dropdown menu, oterwize create hover menu.
public beginMenu ( $name = null, $url = null, $options = [], $linkOptions = [], $listOptions = [] )
    public function beginMenu($name = null, $url = null, $options = [], $linkOptions = [], $listOptions = [])
    {
        $res = '';
        if ($this->_level == 0) {
            $options = is_array($name) ? $name : [];
            $options = $this->addClass($options, ['nav', 'navbar-nav']);
            $res = $this->Html->tag('ul', null, $options);
        } else {
            $linkOptions += ['data-toggle' => 'dropdown', 'role' => 'button', 'aria-haspopup' => 'true', 'aria-expanded' => 'false', 'escape' => false];
            $caret = array_key_exists('caret', $linkOptions) ? $linkOptions['caret'] : '<span class="caret"></span>';
            unset($options['caret']);
            $link = $this->Html->link($name . $caret, $url ? $url : '#', $linkOptions);
            $options = $this->addClass($options, 'dropdown');
            $listOptions = $this->addClass($listOptions, 'dropdown-menu');
            $res = $this->Html->tag('li', null, $options) . $link . $this->Html->tag('ul', null, $listOptions);
        }
        $this->_level += 1;
        return $res;
    }