This repository was archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBase.php
More file actions
61 lines (50 loc) · 1.29 KB
/
Base.php
File metadata and controls
61 lines (50 loc) · 1.29 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace antishov\Morris;
use yii\base\Widget;
class Base extends Widget
{
public $element;
public $data;
public $xKey;
public $yKeys;
public $labels;
public $hideHover;
public $resize = false;
public $gridTextSize = 12;
protected $type;
protected function drawView()
{
$viewTitle = $this->getViewTitle();
$viewOptions = $this->getViewOptions();
return $this->renderFile(__DIR__ . "/views/{$viewTitle}.php", $viewOptions);
}
public function run()
{
parent::run();
$this->registerAssets();
return $this->drawView();
}
protected function getViewTitle()
{
return strtolower($this->type);
}
protected function registerAssets()
{
MorrisAsset::register($this->view);
RaphaelAsset::register($this->view);
}
protected function getViewOptions()
{
return [
'constructor' => $this->type,
'element' => $this->element,
'data' => $this->data,
'xKey' => $this->xKey,
'yKeys' => $this->yKeys,
'labels' => $this->labels,
'hideHover' => $this->hideHover,
'resize' => (int) $this->resize,
'gridTextSize' => $this->gridTextSize,
];
}
}