Commit 8ff4c3d4 by Kartik Visweswaran

Code & minor bug cleanup.

Cleaned up redundant code (and a typo missed earlier).
parent 8a436c4a
...@@ -33,18 +33,18 @@ class Alert extends \yii\bootstrap\Widget ...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment