1
|
|
|
<?php |
2
|
|
|
namespace ViewComponents\Grids; |
3
|
|
|
|
4
|
|
|
use ViewComponents\ViewComponents\Base\ComponentInterface; |
5
|
|
|
use ViewComponents\ViewComponents\Base\Compound\PartInterface; |
6
|
|
|
use ViewComponents\ViewComponents\Base\ContainerComponentInterface; |
7
|
|
|
use ViewComponents\ViewComponents\Base\ViewComponentInterface; |
8
|
|
|
use ViewComponents\ViewComponents\Component\Html\Tag; |
9
|
|
|
use ViewComponents\ViewComponents\Component\Part; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Trait GridPartsAccessTrait |
13
|
|
|
* |
14
|
|
|
* @todo replace Grid::constant to static::constant if it would work |
15
|
|
|
*/ |
16
|
|
|
trait GridPartsAccessTrait |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @param $id |
20
|
|
|
* @param bool $extractView |
21
|
|
|
* @return null|PartInterface|ViewComponentInterface|Part |
22
|
|
|
*/ |
23
|
|
|
abstract public function getComponent($id, $extractView = true); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param ComponentInterface|PartInterface $component |
27
|
|
|
* @param string|null $id |
28
|
|
|
* @param string|null $defaultParent |
29
|
|
|
* @return $this |
30
|
|
|
*/ |
31
|
|
|
abstract public function setComponent(ComponentInterface $component, $id = null, $defaultParent = null); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return Tag |
35
|
|
|
*/ |
36
|
|
|
public function getTable() |
37
|
|
|
{ |
38
|
|
|
return $this->getComponent(Grid::TABLE_ID); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param ComponentInterface $component |
43
|
|
|
* @return $this |
44
|
|
|
*/ |
45
|
|
|
public function setTable(ComponentInterface $component) |
46
|
|
|
{ |
47
|
|
|
return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return Tag |
52
|
|
|
*/ |
53
|
|
|
public function getTableHeading() |
54
|
|
|
{ |
55
|
|
|
return $this->getComponent(Grid::TABLE_HEADING_ID); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param ComponentInterface $component |
60
|
|
|
* @return $this |
61
|
|
|
*/ |
62
|
|
|
public function setTableHeading(ComponentInterface $component) |
63
|
|
|
{ |
64
|
|
|
return $this->setComponent($component, Grid::TABLE_HEADING_ID, Grid::TABLE_ID); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Tag |
69
|
|
|
*/ |
70
|
|
|
public function getTableBody() |
71
|
|
|
{ |
72
|
|
|
return $this->getComponent(Grid::TABLE_BODY_ID); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param ComponentInterface $component |
77
|
|
|
* @return $this |
78
|
|
|
*/ |
79
|
|
|
public function setTableBody(ComponentInterface $component) |
80
|
|
|
{ |
81
|
|
|
return $this->setComponent($component, Grid::TABLE_BODY_ID, Grid::TABLE_ID); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return Tag |
86
|
|
|
*/ |
87
|
|
|
public function getTableFooter() |
88
|
|
|
{ |
89
|
|
|
return $this->getComponent(Grid::TABLE_FOOTER_ID); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param ComponentInterface $component |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
|
|
public function setTableFooter(ComponentInterface $component) |
97
|
|
|
{ |
98
|
|
|
return $this->setComponent($component, Grid::TABLE_FOOTER_ID, Grid::TABLE_ID); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return Tag |
103
|
|
|
*/ |
104
|
|
|
public function getTileRow() |
105
|
|
|
{ |
106
|
|
|
return $this->getComponent(Grid::TITLE_ROW_ID); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param ComponentInterface $component |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
|
|
public function setTitleRow(ComponentInterface $component) |
114
|
|
|
{ |
115
|
|
|
return $this->setComponent($component, Grid::TITLE_ROW_ID, Grid::TABLE_HEADING_ID); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return ContainerComponentInterface |
120
|
|
|
*/ |
121
|
|
|
public function getControlRow() |
122
|
|
|
{ |
123
|
|
|
return $this->getComponent(Grid::CONTROL_ROW_ID); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param ComponentInterface $component |
128
|
|
|
* @return $this |
129
|
|
|
*/ |
130
|
|
|
public function setControlRow(ComponentInterface $component) |
131
|
|
|
{ |
132
|
|
|
return $this->setComponent($component, Grid::CONTROL_ROW_ID, Grid::TABLE_HEADING_ID); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|