renderItem() public method

Renders a widget's item.
public renderItem ( string | array $item ) : string
$item string | array the item to render.
return string the rendering result.
Example #1
0
 /**
  * @inheritdoc
  */
 public function renderItem($item)
 {
     if ($this->route === null && Yii::$app->response !== null) {
         $this->route = Yii::$app->response->getRoute();
     }
     if (isset($item['active'])) {
         if (is_callable($item['active'])) {
             $item['active'] = call_user_func($item['active'], $this, $item);
         }
     }
     return parent::renderItem($item);
 }
Example #2
0
File: Nav.php Project: semnt/tp01
 public function renderItem($item)
 {
     $this->changeItem($item);
     return parent::renderItem($item);
 }
Example #3
0
 /**
  * Renders a widget's item.
  * @param string|array $item the item to render.
  * @return string the rendering result.
  * @throws InvalidConfigException
  */
 public function renderItem($item)
 {
     if (is_string($item)) {
         return $item;
     }
     if (in_array(self::ITEM_DIVIDER, $item, true)) {
         return Html::tag('li', '', ['class' => self::ITEM_DIVIDER]);
     }
     $items = ArrayHelper::getValue($item, 'items');
     if ($items === null) {
         return parent::renderItem($item);
     }
     if (!isset($item['label']) && !isset($item['icon'])) {
         throw new InvalidConfigException("The 'label' option is required.");
     }
     $dropdownType = ArrayHelper::getValue($item, 'dropdownType', self::TYPE_DEFAULT);
     $options = ArrayHelper::getValue($item, 'options', []);
     Html::addCssClass($options, 'dropdown');
     if ($dropdownType !== self::TYPE_DEFAULT) {
         if ($dropdownType !== self::TYPE_USER) {
             Html::addCssClass($options, 'dropdown-extended');
         }
         Html::addCssClass($options, 'dropdown-' . $dropdownType);
         if (Metronic::HEADER_DROPDOWN_DARK === Metronic::getComponent()->headerDropdown) {
             Html::addCssClass($options, 'dropdown-dark');
         }
     }
     if (isset($item['active'])) {
         $active = ArrayHelper::remove($item, 'active', false);
     } else {
         $active = $this->isItemActive($item);
     }
     if ($active) {
         Html::addCssClass($options, 'active');
     }
     return Html::tag('li', sprintf('%s%s', $this->_getLinkTag($item), $this->_getDropdownTag($item)), $options);
 }
Example #4
0
File: Nav.php Project: ASP96/admin
 /**
  * @inheritdoc
  */
 public function renderItem($item)
 {
     return parent::renderItem($this->normalizeItem($item));
 }