<?php namespace common\widgets;use Yii;class Alert extends \yii\bootstrap\Widget{public $alertTypes=[ 'error'=>'alert-danger','danger'=>'alert-danger','success'=>'alert-success','info'=>'alert-info','warning'=>'alert-warning' ];public $closeButton=[];public function run(){$session=Yii::$app->session;$flashes=$session->getAllFlashes();$appendClass=isset($this->options['class'])?' '.$this->options['class']:'';foreach($flashes as $type=>$flash){if(!isset($this->alertTypes[$type])){continue;}foreach((array)$flash as $i=>$message){echo \yii\bootstrap\Alert::widget([ 'body'=>$message,'closeButton'=>$this->closeButton,'options'=>array_merge($this->options,[ 'id'=>$this->getId().'-'.$type.'-'.$i,'class'=>$this->alertTypes[$type].$appendClass,]),]);}$session->removeFlash($type);}}}