-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoxWidget.php
54 lines (44 loc) · 1.13 KB
/
BoxWidget.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: user
* Date: 06.03.2018
* Time: 19:48
*/
namespace wscvua\adminltebox;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
class BoxWidget extends Widget
{
const TYPE_DEFAULT = 1;
const TYPE_PRIMARY = 2;
const TYPE_DANGER = 3;
const TYPE_WARNING = 4;
public $type = self::TYPE_DEFAULT;
public $withBorder = true;
public $afterContent = '';
public $title = 'Title';
public function getClass()
{
return ArrayHelper::getValue([
self::TYPE_DEFAULT => 'default',
self::TYPE_PRIMARY => 'primary',
self::TYPE_DANGER => 'danger',
self::TYPE_WARNING => 'warning',
], $this->type);
}
public function init()
{
parent::init();
ob_start();
}
public function run()
{
$content = ob_get_clean();
$class = $this->getClass();
$withBorder = $this->withBorder;
$afterContent = $this->afterContent;
$title = $this->title;
return $this->render('index', compact('content', 'class', 'withBorder', 'afterContent', 'title'));
}
}