/** * @param null $icon * @param array $options * @return $this */ public function icon($icon, $options = []) { if ($icon === false) { $this->parts['{icon}'] = ''; return $this; } $options = array_merge($this->iconOptions, $options); $this->parts['{icon}'] = Icon::widget(['name' => $icon, 'options' => $options]); return $this; }
/** * Renders the widget. */ public function run() { $content = ''; if ($this->iconName !== null) { $this->iconConfig['name'] = $this->iconName; $content .= Icon::widget($this->iconConfig); } $content .= $this->encodeLabel ? Html::encode($this->label) : $this->label; return Html::tag($this->tagName, $content, $this->options); }
/** * Initializes the widget. */ public function init() { parent::init(); if ($this->route === null && Yii::$app->controller !== null) { $this->route = Yii::$app->controller->getRoute(); } if ($this->params === null) { $this->params = Yii::$app->request->getQueryParams(); } if ($this->dropDownCaret === null) { $this->dropDownCaret = Icon::widget(['name' => 'navigation-arrow-drop-down', 'options' => ['class' => 'right']]); } }