/** * @inheritdoc */ public function run() { $session = Yii::$app->getSession(); $flashes = $session->getAllFlashes(true); if (empty($flashes)) { return; } $view = $this->getView(); BootstrapNotifyAsset::register($view); if ($this->animate) { // FIXME: in pjax responses animate.css does not included in body. AnimateAsset::register($view); } foreach ($flashes as $type => $messages) { $settings = []; switch ($type) { case 'success': case 'info': case 'warning': case 'danger': case 'error': $settings['type'] = $type; break; } if ($this->animate) { $settings['animate'] = $this->animate; } foreach ($messages as $message) { $settings = Json::encode($settings); $view->registerJs("\$.notify('{$message}', {$settings});"); } } }
<?php use app\assets\AnimateAsset; use app\assets\AppAsset; use app\widgets\Notify; use dmstr\web\AdminLteAsset; use yii\helpers\Html; /** @var $this \yii\web\View */ /** @var $content string */ /** @var $directoryAsset string */ AdminLteAsset::register($this); AppAsset::register($this); AnimateAsset::register($this); $directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'); Notify::widget(); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "/> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo Html::csrfMetaTags(); ?>