1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\AdminListBundle\AdminList; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface; |
6
|
|
|
use Pagerfanta\Pagerfanta; |
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* AdminList |
11
|
|
|
*/ |
12
|
|
|
class AdminList |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var Request |
16
|
|
|
*/ |
17
|
|
|
protected $request; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var AdminListConfiguratorInterface |
21
|
|
|
*/ |
22
|
|
|
protected $configurator; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param AdminListConfiguratorInterface $configurator The configurator |
26
|
|
|
*/ |
27
|
30 |
|
public function __construct(AdminListConfiguratorInterface $configurator) |
28
|
|
|
{ |
29
|
30 |
|
$this->configurator = $configurator; |
30
|
30 |
|
$this->configurator->buildFilters(); |
31
|
30 |
|
$this->configurator->buildFields(); |
32
|
30 |
|
$this->configurator->buildItemActions(); |
33
|
30 |
|
$this->configurator->buildListActions(); |
34
|
30 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return AdminListConfiguratorInterface|null |
38
|
|
|
*/ |
39
|
1 |
|
public function getConfigurator() |
40
|
|
|
{ |
41
|
1 |
|
return $this->configurator; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return FilterBuilder |
46
|
|
|
*/ |
47
|
1 |
|
public function getFilterBuilder() |
48
|
|
|
{ |
49
|
1 |
|
return $this->configurator->getFilterBuilder(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param Request $request |
54
|
|
|
*/ |
55
|
|
|
public function bindRequest(Request $request) |
56
|
|
|
{ |
57
|
|
|
$this->configurator->bindRequest($request); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Field[] |
62
|
|
|
*/ |
63
|
1 |
|
public function getColumns() |
64
|
|
|
{ |
65
|
1 |
|
return $this->configurator->getFields(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return Field[] |
70
|
|
|
*/ |
71
|
1 |
|
public function getExportColumns() |
72
|
|
|
{ |
73
|
1 |
|
return $this->configurator->getExportFields(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
1 |
|
public function getCount() |
80
|
|
|
{ |
81
|
1 |
|
return $this->configurator->getCount(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return array|null |
86
|
|
|
*/ |
87
|
1 |
|
public function getItems() |
88
|
|
|
{ |
89
|
1 |
|
return $this->configurator->getItems(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Return an iterator for all items that matches the current filtering |
94
|
|
|
* |
95
|
|
|
* @return \Iterator |
96
|
|
|
*/ |
97
|
|
|
public function getIterator() |
98
|
|
|
{ |
99
|
|
|
return $this->configurator->getIterator(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $columnName |
|
|
|
|
104
|
|
|
* |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
1 |
|
public function hasSort($columnName = null) |
108
|
|
|
{ |
109
|
1 |
|
if (\is_null($columnName)) { |
110
|
1 |
|
return \count($this->configurator->getSortFields()) > 0; |
111
|
|
|
} |
112
|
|
|
|
113
|
1 |
|
return \in_array($columnName, $this->configurator->getSortFields()); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param mixed $item |
118
|
|
|
* |
119
|
|
|
* @return bool |
120
|
|
|
*/ |
121
|
1 |
|
public function canEdit($item) |
122
|
|
|
{ |
123
|
1 |
|
return $this->configurator->canEdit($item); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return bool |
128
|
|
|
*/ |
129
|
1 |
|
public function canAdd() |
130
|
|
|
{ |
131
|
1 |
|
return $this->configurator->canAdd(); |
132
|
|
|
} |
133
|
|
|
|
134
|
1 |
|
public function canView($item) |
|
|
|
|
135
|
|
|
{ |
136
|
1 |
|
return $this->configurator->canView($item); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return array |
141
|
|
|
*/ |
142
|
1 |
|
public function getIndexUrl() |
143
|
|
|
{ |
144
|
1 |
|
return $this->configurator->getIndexUrl(); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param mixed $item |
149
|
|
|
* |
150
|
|
|
* @return array |
151
|
|
|
*/ |
152
|
1 |
|
public function getEditUrlFor($item) |
153
|
|
|
{ |
154
|
1 |
|
return $this->configurator->getEditUrlFor($item); |
155
|
|
|
} |
156
|
|
|
|
157
|
1 |
|
public function getViewUrlFor($item) |
158
|
|
|
{ |
159
|
1 |
|
return $this->configurator->getViewUrlFor($item); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param mixed $item |
164
|
|
|
* |
165
|
|
|
* @return array |
166
|
|
|
*/ |
167
|
1 |
|
public function getDeleteUrlFor($item) |
168
|
|
|
{ |
169
|
1 |
|
return $this->configurator->getDeleteUrlFor($item); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param array $params |
174
|
|
|
* |
175
|
|
|
* @return array |
176
|
|
|
*/ |
177
|
1 |
|
public function getAddUrlFor(array $params) |
178
|
|
|
{ |
179
|
1 |
|
return $this->configurator->getAddUrlFor($params); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param mixed $item |
184
|
|
|
* |
185
|
|
|
* @return bool |
186
|
|
|
*/ |
187
|
1 |
|
public function canDelete($item) |
188
|
|
|
{ |
189
|
1 |
|
return $this->configurator->canDelete($item); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return bool |
194
|
|
|
*/ |
195
|
1 |
|
public function canExport() |
196
|
|
|
{ |
197
|
1 |
|
return $this->configurator->canExport(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return array |
202
|
|
|
*/ |
203
|
1 |
|
public function getExportUrl() |
204
|
|
|
{ |
205
|
1 |
|
return $this->configurator->getExportUrl(); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param object|array $object The object |
210
|
|
|
* @param string $attribute The attribute |
211
|
|
|
* |
212
|
|
|
* @return mixed |
213
|
|
|
*/ |
214
|
1 |
|
public function getValue($object, $attribute) |
215
|
|
|
{ |
216
|
1 |
|
return $this->configurator->getValue($object, $attribute); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @param object|array $object The object |
221
|
|
|
* @param string $attribute The attribute |
222
|
|
|
* |
223
|
|
|
* @return string |
224
|
|
|
*/ |
225
|
1 |
|
public function getStringValue($object, $attribute) |
226
|
|
|
{ |
227
|
1 |
|
return $this->configurator->getStringValue($object, $attribute); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return string |
232
|
|
|
*/ |
233
|
1 |
|
public function getOrderBy() |
234
|
|
|
{ |
235
|
1 |
|
return $this->configurator->getOrderBy(); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return string |
240
|
|
|
*/ |
241
|
1 |
|
public function getOrderDirection() |
242
|
|
|
{ |
243
|
1 |
|
return $this->configurator->getOrderDirection(); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @return array |
|
|
|
|
248
|
|
|
*/ |
249
|
1 |
|
public function getItemActions() |
250
|
|
|
{ |
251
|
1 |
|
return $this->configurator->getItemActions(); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @return bool |
256
|
|
|
*/ |
257
|
1 |
|
public function hasItemActions() |
258
|
|
|
{ |
259
|
1 |
|
return $this->configurator->hasItemActions(); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @return bool |
264
|
|
|
*/ |
265
|
1 |
|
public function hasListActions() |
266
|
|
|
{ |
267
|
1 |
|
return $this->configurator->hasListActions(); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @return array |
|
|
|
|
272
|
|
|
*/ |
273
|
1 |
|
public function getListActions() |
274
|
|
|
{ |
275
|
1 |
|
return $this->configurator->getListActions(); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @return array |
|
|
|
|
280
|
|
|
*/ |
281
|
1 |
|
public function getBulkActions() |
282
|
|
|
{ |
283
|
1 |
|
return $this->configurator->getBulkActions(); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @return bool |
288
|
|
|
*/ |
289
|
1 |
|
public function hasBulkActions() |
290
|
|
|
{ |
291
|
1 |
|
return $this->configurator->hasBulkActions(); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @return Pagerfanta |
296
|
|
|
*/ |
297
|
1 |
|
public function getPagerfanta() |
298
|
|
|
{ |
299
|
1 |
|
return $this->configurator->getPagerfanta(); |
300
|
|
|
} |
301
|
|
|
} |
302
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.