/** * Initialization Widgets */ public function init() { parent::init(); $this->options = ArrayHelper::merge($this->_options, $this->options); $this->view->registerAssetBundle(GritterAsset::className()); $session = Yii::$app->getSession(); $this->showFlashes($session); }
public function init() { parent::init(); $this->view->registerAssetBundle(GritterAsset::className()); $session = Yii::$app->getSession(); $flashes = $session->getAllFlashes(); foreach ($flashes as $type => $data) { if (isset($this->gritterTypes[$type])) { $data = (array) $data; foreach ($data as $i => $message) { $title = $this->title[$type]; if ($this->enableIcon) { $title = Html::tag('i', '', ['class' => $this->gritterIcons[$type]]) . $title; } $this->registerJS($title, $message, $this->gritterTypes[$type] . ' gritter-icon', '', false, $this->gritterOptions); } $session->removeFlash($type); } } }