1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dtc\GridBundle\Grid\Renderer; |
4
|
|
|
|
5
|
|
|
use Dtc\GridBundle\Grid\Source\GridSourceInterface; |
6
|
|
|
|
7
|
|
|
abstract class AbstractRenderer |
8
|
|
|
{ |
9
|
|
|
/** @var GridSourceInterface */ |
10
|
|
|
protected $gridSource; |
11
|
|
|
|
12
|
|
|
protected $options; |
13
|
|
|
|
14
|
|
|
protected $themeCss; |
15
|
|
|
protected $themeJs; |
16
|
|
|
protected $pageDivStyle; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param array|null $params Will be populated if passed in |
20
|
|
|
*/ |
21
|
|
|
public function getParams(array &$params = null) |
22
|
|
|
{ |
23
|
|
|
if (null === $params) { |
24
|
|
|
$params = []; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$params['dtc_grid'] = $this; |
28
|
|
|
$params['dtc_grid_theme_css'] = $this->themeCss; |
29
|
|
|
$params['dtc_grid_theme_js'] = $this->themeJs; |
30
|
|
|
$params['dtc_grid_page_div_style'] = $this->pageDivStyle; |
31
|
|
|
$params['dtc_grid_local_css'] = []; |
32
|
|
|
$params['dtc_grid_local_js'] = []; |
33
|
|
|
|
34
|
|
|
return $params; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function setOptions(array $values) |
38
|
|
|
{ |
39
|
|
|
$this->options = $values; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function setOption($key, $value) |
43
|
|
|
{ |
44
|
|
|
$this->options[$key] = $value; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function bind(GridSourceInterface $gridSource) |
48
|
|
|
{ |
49
|
|
|
$this->gridSource = $gridSource; |
50
|
|
|
$this->afterBind(); |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getGridOptions() |
56
|
|
|
{ |
57
|
|
|
return $this->options; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function afterBind() |
61
|
|
|
{ |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function getThemeCss() |
68
|
|
|
{ |
69
|
|
|
return $this->themeCss; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param mixed $bootstrapCss |
74
|
|
|
*/ |
75
|
|
|
public function setThemeCss(array $themeCss) |
76
|
|
|
{ |
77
|
|
|
$this->themeCss = $themeCss; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return mixed |
82
|
|
|
*/ |
83
|
|
|
public function getThemeJs() |
84
|
|
|
{ |
85
|
|
|
return $this->themeJs; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param mixed $bootstrapJs |
90
|
|
|
*/ |
91
|
|
|
public function setThemeJs(array $themeJs) |
92
|
|
|
{ |
93
|
|
|
$this->themeJs = $themeJs; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return mixed |
98
|
|
|
*/ |
99
|
|
|
public function getPageDivStyle() |
100
|
|
|
{ |
101
|
|
|
return $this->pageDivStyle; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param mixed $pageDivStyle |
106
|
|
|
*/ |
107
|
|
|
public function setPageDivStyle($pageDivStyle) |
108
|
|
|
{ |
109
|
|
|
$this->pageDivStyle = $pageDivStyle; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
abstract public function render(); |
113
|
|
|
} |
114
|
|
|
|