-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGridView.php
66 lines (55 loc) · 1.44 KB
/
GridView.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
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace consultnn\grid;
use Yii;
class GridView extends \yii\grid\GridView
{
const EVENT_AFTER_INIT = 'afterInit';
const EVENT_BEFORE_RUN = 'beforeRun';
const EVENT_AFTER_RUN = 'afterRun';
public $pluginSections = [];
public $layout = "{summary}{settings}\n{items}\n{pager}";
/**
* @var array|plugins\AbstractPlugin[]
*/
public $plugins = [];
public function init()
{
$this->initPlugins();
parent::init();
$this->trigger(self::EVENT_AFTER_INIT);
}
public function run()
{
$this->trigger(self::EVENT_BEFORE_RUN);
parent::run();
$this->trigger(self::EVENT_AFTER_RUN);
}
protected function initPlugins()
{
foreach ($this->plugins as $key => $pluginOptions) {
if (is_string($pluginOptions)) {
$pluginOptions = [
'class' => $pluginOptions
];
}
$this->plugins[$key] = Yii::createObject(array_merge(
[
'grid' => $this,
'id' => $this->id
],
$pluginOptions
));
}
}
/**
* @inheritdoc
*/
public function renderSection($name)
{
if (isset($this->pluginSections[$name])) {
return $this->pluginSections[$name]->run();
} else {
return parent::renderSection($name);
}
}
}