NavModule::addDropdown PHP Method

addDropdown() public method

Add a dropdown menu to the items array.
public addDropdown ( DropdownModule $dropdown, string $key = '', string $cssClass = '', array | integer $sort = [] ) : NavModule
$dropdown DropdownModule The dropdown menu to add.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The dropdown wrapper's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
return NavModule $this The calling object.
    public function addDropdown($dropdown, $key = '', $cssClass = '', $sort = array())
    {
        if (is_a($dropdown, 'DropdownModule')) {
            $dropdown->tag = 'li';
            $dropdown->prepare();
            $dropdownItem['type'] = 'dropdown';
            if ($key) {
                $dropdownItem['key'] = $key;
            }
            if ($sort) {
                $dropdownItem['sort'] = $sort;
            }
            $dropdownItem['dropdownmenu'] = $dropdown;
            $dropdownItem['cssClass'] = $cssClass . ' ' . $this->buildCssClass($this->dropdownCssClassPrefix, $dropdownItem);
            $this->addItem('dropdown', $dropdownItem);
        }
        return $this;
    }