|
1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\Table\Component\View; |
|
2
|
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Traits\FiresCallbacks; |
|
4
|
|
|
use Anomaly\Streams\Platform\Ui\Table\Component\View\Contract\ViewInterface; |
|
5
|
|
|
use Closure; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class View |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://pyrocms.com/ |
|
11
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
|
12
|
|
|
* @author Ryan Thompson <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
class View implements ViewInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
use FiresCallbacks; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* The view slug. |
|
21
|
|
|
* |
|
22
|
|
|
* @var null|string |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $slug = null; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The view text. |
|
28
|
|
|
* |
|
29
|
|
|
* @var null|string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $text = null; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The view icon. |
|
35
|
|
|
* |
|
36
|
|
|
* @var null|string |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $icon = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The active flag. |
|
42
|
|
|
* |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $active = false; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* The view prefix. |
|
49
|
|
|
* |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $prefix = null; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* The attributes array. |
|
56
|
|
|
* |
|
57
|
|
|
* @var array |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $attributes = []; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* The view filters. |
|
63
|
|
|
* |
|
64
|
|
|
* @var null |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $filters = null; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* The view columns. |
|
70
|
|
|
* |
|
71
|
|
|
* @var null |
|
72
|
|
|
*/ |
|
73
|
|
|
protected $columns = null; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* The view buttons. |
|
77
|
|
|
* |
|
78
|
|
|
* @var null |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $buttons = null; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* The view actions. |
|
84
|
|
|
* |
|
85
|
|
|
* @var null |
|
86
|
|
|
*/ |
|
87
|
|
|
protected $actions = null; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* The view options. |
|
91
|
|
|
* |
|
92
|
|
|
* @var null |
|
93
|
|
|
*/ |
|
94
|
|
|
protected $options = null; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* The view handler. |
|
98
|
|
|
* |
|
99
|
|
|
* @var callable|null|string |
|
100
|
|
|
*/ |
|
101
|
|
|
protected $handler = null; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* The view query. |
|
105
|
|
|
* |
|
106
|
|
|
* @var null|string|Closure |
|
107
|
|
|
*/ |
|
108
|
|
|
protected $query = null; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Get the attributes. |
|
112
|
|
|
* |
|
113
|
|
|
* @return array |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getAttributes() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->attributes; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Set the attributes. |
|
122
|
|
|
* |
|
123
|
|
|
* @param array $attributes |
|
124
|
|
|
* @return $this |
|
125
|
|
|
*/ |
|
126
|
|
|
public function setAttributes(array $attributes) |
|
127
|
|
|
{ |
|
128
|
|
|
$this->attributes = $attributes; |
|
129
|
|
|
|
|
130
|
|
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get the view handler. |
|
135
|
|
|
* |
|
136
|
|
|
* @return callable|null|string |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getHandler() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->handler; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Set the view handler. |
|
145
|
|
|
* |
|
146
|
|
|
* @param $handler |
|
147
|
|
|
* @return $this |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setHandler($handler) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->handler = $handler; |
|
152
|
|
|
|
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Get the query. |
|
158
|
|
|
* |
|
159
|
|
|
* @return callable|null|string |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getQuery() |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->query; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Set the query. |
|
168
|
|
|
* |
|
169
|
|
|
* @param $query |
|
170
|
|
|
* @return $this |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setQuery($query) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->query = $query; |
|
175
|
|
|
|
|
176
|
|
|
return $this; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Set the active flag. |
|
181
|
|
|
* |
|
182
|
|
|
* @param bool $active |
|
183
|
|
|
* @return $this |
|
184
|
|
|
*/ |
|
185
|
|
|
public function setActive($active) |
|
186
|
|
|
{ |
|
187
|
|
|
$this->active = $active; |
|
188
|
|
|
|
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Get the active flag. |
|
194
|
|
|
* |
|
195
|
|
|
* @return bool |
|
196
|
|
|
*/ |
|
197
|
|
|
public function isActive() |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->active; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* Get the view prefix. |
|
204
|
|
|
* |
|
205
|
|
|
* @return string |
|
206
|
|
|
*/ |
|
207
|
|
|
public function getPrefix() |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->prefix; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* Set the view prefix. |
|
214
|
|
|
* |
|
215
|
|
|
* @param $prefix |
|
216
|
|
|
* @return $this |
|
217
|
|
|
*/ |
|
218
|
|
|
public function setPrefix($prefix) |
|
219
|
|
|
{ |
|
220
|
|
|
$this->prefix = $prefix; |
|
221
|
|
|
|
|
222
|
|
|
return $this; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Get the view slug. |
|
227
|
|
|
* |
|
228
|
|
|
* @return string |
|
229
|
|
|
*/ |
|
230
|
|
|
public function getSlug() |
|
231
|
|
|
{ |
|
232
|
|
|
return $this->slug; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Set the view slug. |
|
237
|
|
|
* |
|
238
|
|
|
* @param $slug |
|
239
|
|
|
* @return $this |
|
240
|
|
|
*/ |
|
241
|
|
|
public function setSlug($slug) |
|
242
|
|
|
{ |
|
243
|
|
|
$this->slug = $slug; |
|
244
|
|
|
|
|
245
|
|
|
return $this; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* Get the view text. |
|
250
|
|
|
* |
|
251
|
|
|
* @return string |
|
252
|
|
|
*/ |
|
253
|
|
|
public function getText() |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->text; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* Set the view text. |
|
260
|
|
|
* |
|
261
|
|
|
* @param string $text |
|
262
|
|
|
* @return $this |
|
263
|
|
|
*/ |
|
264
|
|
|
public function setText($text) |
|
265
|
|
|
{ |
|
266
|
|
|
$this->text = $text; |
|
267
|
|
|
|
|
268
|
|
|
return $this; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* Get the icon. |
|
273
|
|
|
* |
|
274
|
|
|
* @return null|string |
|
275
|
|
|
*/ |
|
276
|
|
|
public function getIcon() |
|
277
|
|
|
{ |
|
278
|
|
|
return $this->icon; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* Set the icon. |
|
283
|
|
|
* |
|
284
|
|
|
* @param $icon |
|
285
|
|
|
* @return $this |
|
286
|
|
|
*/ |
|
287
|
|
|
public function setIcon($icon) |
|
288
|
|
|
{ |
|
289
|
|
|
$this->icon = $icon; |
|
290
|
|
|
|
|
291
|
|
|
return $this; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
/** |
|
295
|
|
|
* Get the filters. |
|
296
|
|
|
* |
|
297
|
|
|
* @return null|array |
|
298
|
|
|
*/ |
|
299
|
|
|
public function getFilters() |
|
300
|
|
|
{ |
|
301
|
|
|
return $this->filters; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* Set the filters. |
|
306
|
|
|
* |
|
307
|
|
|
* @param $filters |
|
308
|
|
|
* @return $this |
|
309
|
|
|
*/ |
|
310
|
|
|
public function setFilters($filters) |
|
311
|
|
|
{ |
|
312
|
|
|
$this->filters = $filters; |
|
313
|
|
|
|
|
314
|
|
|
return $this; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* Get the columns. |
|
319
|
|
|
* |
|
320
|
|
|
* @return null|array |
|
321
|
|
|
*/ |
|
322
|
|
|
public function getColumns() |
|
323
|
|
|
{ |
|
324
|
|
|
return $this->columns; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
/** |
|
328
|
|
|
* Set the columns. |
|
329
|
|
|
* |
|
330
|
|
|
* @param $columns |
|
331
|
|
|
* @return $this |
|
332
|
|
|
*/ |
|
333
|
|
|
public function setColumns($columns) |
|
334
|
|
|
{ |
|
335
|
|
|
$this->columns = $columns; |
|
336
|
|
|
|
|
337
|
|
|
return $this; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* Get the buttons. |
|
342
|
|
|
* |
|
343
|
|
|
* @return null|array |
|
344
|
|
|
*/ |
|
345
|
|
|
public function getButtons() |
|
346
|
|
|
{ |
|
347
|
|
|
return $this->buttons; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* Set the buttons. |
|
352
|
|
|
* |
|
353
|
|
|
* @param $buttons |
|
354
|
|
|
* @return $this |
|
355
|
|
|
*/ |
|
356
|
|
|
public function setButtons($buttons) |
|
357
|
|
|
{ |
|
358
|
|
|
$this->buttons = $buttons; |
|
359
|
|
|
|
|
360
|
|
|
return $this; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Get the actions. |
|
365
|
|
|
* |
|
366
|
|
|
* @return null|array |
|
367
|
|
|
*/ |
|
368
|
|
|
public function getActions() |
|
369
|
|
|
{ |
|
370
|
|
|
return $this->actions; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* Set the actions. |
|
375
|
|
|
* |
|
376
|
|
|
* @param $actions |
|
377
|
|
|
* @return $this |
|
378
|
|
|
*/ |
|
379
|
|
|
public function setActions($actions) |
|
380
|
|
|
{ |
|
381
|
|
|
$this->actions = $actions; |
|
382
|
|
|
|
|
383
|
|
|
return $this; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Get the options. |
|
388
|
|
|
* |
|
389
|
|
|
* @return null|array |
|
390
|
|
|
*/ |
|
391
|
|
|
public function getOptions() |
|
392
|
|
|
{ |
|
393
|
|
|
return $this->options; |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* Set the options. |
|
398
|
|
|
* |
|
399
|
|
|
* @param $options |
|
400
|
|
|
* @return $this |
|
401
|
|
|
*/ |
|
402
|
|
|
public function setOptions($options) |
|
403
|
|
|
{ |
|
404
|
|
|
$this->options = $options; |
|
405
|
|
|
|
|
406
|
|
|
return $this; |
|
407
|
|
|
} |
|
408
|
|
|
} |
|
409
|
|
|
|