'nav-item']; public $linkTemplate = ' {icon}
{label}
{right-icon} {badge}
'; public $labelTemplate = '{icon}{label}{badge}'; public $badgeTag = 'span'; public $badgeClass = 'badge ml-auto'; public $badgeBgClass; public $parentRightIcon = ''; protected function renderItem($item) { $item['badgeOptions'] = $item['badgeOptions'] ?? []; if (!ArrayHelper::getValue($item, 'badgeOptions.class')) { $bg = $item['badgeBgClass'] ?? $this->badgeBgClass; $item['badgeOptions']['class'] = $this->badgeClass . ' ' . $bg; } if (isset($item['items']) && !isset($item['right-icon'])) { $item['right-icon'] = $this->parentRightIcon; } if (isset($item['url'])) { $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate); return strtr($template, [ '{badge}' => isset($item['badge']) ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => $item['icon'] ?? '', '{right-icon}' => $item['right-icon'] ?? '', '{url}' => Url::to($item['url']), '{label}' => $item['label'], ]); } else { $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate); return strtr($template, [ '{badge}' => isset($item['badge']) ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => $item['icon'] ?? '', '{right-icon}' => $item['right-icon'] ?? '', '{label}' => $item['label'], ]); } } }