FlashWidget.php
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace artbox\core\widgets;
use yii\base\Widget;
use Yii;
/**
* Class FleshWidget
*
* @package artbox\core\widgets
*/
class FlashWidget extends Widget
{
public $flashes = [
'success',
'info',
'warning',
'error',
];
public function run()
{
foreach ($this->flashes as $flash) {
if (Yii::$app->session->hasFlash($flash)) {
$message = Yii::$app->session->getFlash($flash);
$js = '
new PNotify({
title: "' . Yii::t('core', 'Notification') . ':",
text: "' . $message . '",
type: "' . $flash . '",
styling: "bootstrap3",
icon: "glyphicon glyphicon-exclamation-sign"
});
';
return $this->render('_flash', [ 'js' => $js ]);
}
}
return '';
}
}