NavModule::addDropdownIf PHP Метод

addDropdownIf() публичный Метод

Add a dropdown to the items array if it satisfies the $isAllowed condition.
public addDropdownIf ( boolean | string | array $isAllowed = true, DropdownModule $dropdown, string $key = '', string $cssClass = '', array | integer $sort = [] ) : NavModule
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$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').
Результат NavModule $this The calling object.
    public function addDropdownIf($isAllowed = true, $dropdown, $key = '', $cssClass = '', $sort = array())
    {
        if (!$this->isAllowed($isAllowed)) {
            return $this;
        } else {
            return $this->addDropdown($dropdown, $key, $cssClass, $sort);
        }
    }