|
|
@ -33,18 +33,18 @@ class Alert extends \yii\bootstrap\Widget |
|
|
|
public function init() |
|
|
|
public function init() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$session = \Yii::$app->getSession(); |
|
|
|
$session = \Yii::$app->getSession(); |
|
|
|
$appendCss = isset($this->options['class']) ? $this->options['class'] : ''; |
|
|
|
$flashes = $session->getAllFlashes(); |
|
|
|
|
|
|
|
$appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : ''; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($flashes as $type => $message) { |
|
|
|
foreach ($flashes as $type => $message) { |
|
|
|
if (in_array($type, $this->allowedTypes)) { |
|
|
|
if (in_array($type, $this->allowedTypes)) { |
|
|
|
$this->options['class'] = (($type === 'error') ? 'alert-danger' : 'alert-' . $type) . ' ' . $appendCss; |
|
|
|
$this->options['class'] = (($type === 'error') ? 'alert-danger' : 'alert-' . $type) . $appendCss; |
|
|
|
echo \yii\bootstrap\Alert::widget([ |
|
|
|
echo \yii\bootstrap\Alert::widget([ |
|
|
|
'body' => $message, |
|
|
|
'body' => $message, |
|
|
|
'closeButton' => $this->closeButton, |
|
|
|
'closeButton' => $this->closeButton, |
|
|
|
'options' => $this->options |
|
|
|
'options' => $this->options |
|
|
|
]); |
|
|
|
]); |
|
|
|
$session->removeFlash($type); |
|
|
|
$session->removeFlash($type); |
|
|
|
$this->_doNotRender = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
parent::init(); |
|
|
|
parent::init(); |
|
|
|