yii\bootstrap\Dropdown::init PHP Метод

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

If you override this method, make sure you call the parent implementation first.
public init ( )
    public function init()
    {
        if ($this->submenuOptions === null) {
            // copying of [[options]] kept for BC
            // @todo separate [[submenuOptions]] from [[options]] completely before 2.1 release
            $this->submenuOptions = $this->options;
            unset($this->submenuOptions['id']);
        }
        parent::init();
        Html::addCssClass($this->options, ['widget' => 'dropdown-menu']);
    }

Usage Example

Пример #1
0
 public function init()
 {
     $route = Yii::$app->controller->route;
     //$defaultLanguage = Lang::getDefaultLang();
     $appLanguage = Yii::$app->language;
     //$appLanguage = $defaultLanguage->getAttribute('url');
     $params = $_GET;
     $this->_isError = $route === Yii::$app->errorHandler->errorAction;
     array_unshift($params, '/' . $route);
     $languages = Lang::find()->all();
     foreach ($languages as $language) {
         if ($language === $appLanguage) {
             continue;
             // Exclude the current language
         }
         $params['language'] = $language->getAttribute('url');
         $this->items[] = ['label' => self::label($language->getAttribute('url')), 'url' => $params];
     }
     parent::init();
 }
All Usage Examples Of yii\bootstrap\Dropdown::init