1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section\Contract\SectionInterface; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Section |
7
|
|
|
* |
8
|
|
|
* @link http://anomaly.is/streams-platform |
9
|
|
|
* @author AnomalyLabs, Inc. <[email protected]> |
10
|
|
|
* @author Ryan Thompson <[email protected]> |
11
|
|
|
* @package Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section |
12
|
|
|
*/ |
13
|
|
|
class Section implements SectionInterface |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The section slug. |
18
|
|
|
* |
19
|
|
|
* @var null|string |
20
|
|
|
*/ |
21
|
|
|
protected $slug = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The section icon. |
25
|
|
|
* |
26
|
|
|
* @var null|string |
27
|
|
|
*/ |
28
|
|
|
protected $icon = null; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The section title. |
32
|
|
|
* |
33
|
|
|
* @var null|string |
34
|
|
|
*/ |
35
|
|
|
protected $title = null; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The class. |
39
|
|
|
* |
40
|
|
|
* @var null|string |
41
|
|
|
*/ |
42
|
|
|
protected $class = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The active flag. |
46
|
|
|
* |
47
|
|
|
* @var bool |
48
|
|
|
*/ |
49
|
|
|
protected $active = false; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The path matcher. |
53
|
|
|
* |
54
|
|
|
* @var null|string |
55
|
|
|
*/ |
56
|
|
|
protected $matcher = null; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The section description. |
60
|
|
|
* |
61
|
|
|
* @var null|string |
62
|
|
|
*/ |
63
|
|
|
protected $description = null; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The highlighted flag. |
67
|
|
|
* |
68
|
|
|
* @var bool |
69
|
|
|
*/ |
70
|
|
|
protected $highlighted = false; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* The section parent. |
74
|
|
|
* |
75
|
|
|
* @var null|string |
76
|
|
|
*/ |
77
|
|
|
protected $parent = null; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Section buttons. These are only to |
81
|
|
|
* transport input to the button builder. |
82
|
|
|
* |
83
|
|
|
* @var array |
84
|
|
|
*/ |
85
|
|
|
protected $buttons = []; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* The section attributes. |
89
|
|
|
* |
90
|
|
|
* @var array |
91
|
|
|
*/ |
92
|
|
|
protected $attributes = []; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* The section permission. |
96
|
|
|
* |
97
|
|
|
* @var null|string |
98
|
|
|
*/ |
99
|
|
|
protected $permission = null; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* The section breadcrumb. |
103
|
|
|
* |
104
|
|
|
* @var null|string |
105
|
|
|
*/ |
106
|
|
|
protected $breadcrumb = null; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Get the slug. |
110
|
|
|
* |
111
|
|
|
* @return null|string |
112
|
|
|
*/ |
113
|
|
|
public function getSlug() |
114
|
|
|
{ |
115
|
|
|
return $this->slug; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set the slug. |
120
|
|
|
* |
121
|
|
|
* @param $slug |
122
|
|
|
* @return $this |
123
|
|
|
*/ |
124
|
|
|
public function setSlug($slug) |
125
|
|
|
{ |
126
|
|
|
$this->slug = $slug; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get the icon. |
133
|
|
|
* |
134
|
|
|
* @return null|string |
135
|
|
|
*/ |
136
|
|
|
public function getIcon() |
137
|
|
|
{ |
138
|
|
|
return $this->icon; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Set the icon. |
143
|
|
|
* |
144
|
|
|
* @param $icon |
145
|
|
|
* @return $this |
146
|
|
|
*/ |
147
|
|
|
public function setIcon($icon) |
148
|
|
|
{ |
149
|
|
|
$this->icon = $icon; |
150
|
|
|
|
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Get the title. |
156
|
|
|
* |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
|
|
public function getTitle() |
160
|
|
|
{ |
161
|
|
|
return $this->title; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Set the title. |
166
|
|
|
* |
167
|
|
|
* @param string $title |
168
|
|
|
*/ |
169
|
|
|
public function setTitle($title) |
170
|
|
|
{ |
171
|
|
|
$this->title = $title; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get the class. |
176
|
|
|
* |
177
|
|
|
* @return string |
178
|
|
|
*/ |
179
|
|
|
public function getClass() |
180
|
|
|
{ |
181
|
|
|
return $this->class; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Set the class. |
186
|
|
|
* |
187
|
|
|
* @param $class |
188
|
|
|
* @return $this |
189
|
|
|
*/ |
190
|
|
|
public function setClass($class) |
191
|
|
|
{ |
192
|
|
|
$this->class = $class; |
193
|
|
|
|
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Get the active flag. |
199
|
|
|
* |
200
|
|
|
* @return boolean |
201
|
|
|
*/ |
202
|
|
|
public function isActive() |
203
|
|
|
{ |
204
|
|
|
return $this->active; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Set the active flag. |
209
|
|
|
* |
210
|
|
|
* @param boolean $active |
211
|
|
|
*/ |
212
|
|
|
public function setActive($active) |
213
|
|
|
{ |
214
|
|
|
$this->active = $active; |
215
|
|
|
|
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Get the matcher. |
221
|
|
|
* |
222
|
|
|
* @return null|string |
223
|
|
|
*/ |
224
|
|
|
public function getMatcher() |
225
|
|
|
{ |
226
|
|
|
return $this->matcher; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* Set the matcher. |
231
|
|
|
* |
232
|
|
|
* @param $matcher |
233
|
|
|
* @return $this |
234
|
|
|
*/ |
235
|
|
|
public function setMatcher($matcher) |
236
|
|
|
{ |
237
|
|
|
$this->matcher = $matcher; |
238
|
|
|
|
239
|
|
|
return $this; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Get the description. |
244
|
|
|
* |
245
|
|
|
* @return null|string |
246
|
|
|
*/ |
247
|
|
|
public function getDescription() |
248
|
|
|
{ |
249
|
|
|
return $this->description; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Set the description. |
254
|
|
|
* |
255
|
|
|
* @param $description |
256
|
|
|
* @return $this |
257
|
|
|
*/ |
258
|
|
|
public function setDescription($description) |
259
|
|
|
{ |
260
|
|
|
$this->description = $description; |
261
|
|
|
|
262
|
|
|
return $this; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Get the highlighted flag. |
267
|
|
|
* |
268
|
|
|
* @return boolean |
269
|
|
|
*/ |
270
|
|
|
public function isHighlighted() |
271
|
|
|
{ |
272
|
|
|
return $this->highlighted; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Set the highlighted flag. |
277
|
|
|
* |
278
|
|
|
* @param boolean $active |
|
|
|
|
279
|
|
|
* @return $this |
280
|
|
|
*/ |
281
|
|
|
public function setHighlighted($highlighted) |
282
|
|
|
{ |
283
|
|
|
$this->highlighted = $highlighted; |
284
|
|
|
|
285
|
|
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Get the parent. |
290
|
|
|
* |
291
|
|
|
* @return null|string |
292
|
|
|
*/ |
293
|
|
|
public function getParent() |
294
|
|
|
{ |
295
|
|
|
return $this->parent; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Set the parent. |
300
|
|
|
* |
301
|
|
|
* @param $parent |
302
|
|
|
* @return $this |
303
|
|
|
*/ |
304
|
|
|
public function setParent($parent) |
305
|
|
|
{ |
306
|
|
|
$this->parent = $parent; |
307
|
|
|
|
308
|
|
|
return $this; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Get the buttons. |
313
|
|
|
* |
314
|
|
|
* @return array |
315
|
|
|
*/ |
316
|
|
|
public function getButtons() |
317
|
|
|
{ |
318
|
|
|
return $this->buttons; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Set the buttons. |
323
|
|
|
* |
324
|
|
|
* @param array $buttons |
325
|
|
|
*/ |
326
|
|
|
public function setButtons($buttons) |
327
|
|
|
{ |
328
|
|
|
$this->buttons = $buttons; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Get the attributes. |
333
|
|
|
* |
334
|
|
|
* @return array |
335
|
|
|
*/ |
336
|
|
|
public function getAttributes() |
337
|
|
|
{ |
338
|
|
|
return $this->attributes; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* Set the attributes. |
343
|
|
|
* |
344
|
|
|
* @param array $attributes |
345
|
|
|
*/ |
346
|
|
|
public function setAttributes(array $attributes) |
347
|
|
|
{ |
348
|
|
|
$this->attributes = $attributes; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Get the permission. |
353
|
|
|
* |
354
|
|
|
* @return null|string |
355
|
|
|
*/ |
356
|
|
|
public function getPermission() |
357
|
|
|
{ |
358
|
|
|
return $this->permission; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Set the permission. |
363
|
|
|
* |
364
|
|
|
* @param $permission |
365
|
|
|
* @return $this |
366
|
|
|
*/ |
367
|
|
|
public function setPermission($permission) |
368
|
|
|
{ |
369
|
|
|
$this->permission = $permission; |
370
|
|
|
|
371
|
|
|
return $this; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* Get the breadcrumb. |
376
|
|
|
* |
377
|
|
|
* @return null|string |
378
|
|
|
*/ |
379
|
|
|
public function getBreadcrumb() |
380
|
|
|
{ |
381
|
|
|
return $this->breadcrumb; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Set the breadcrumb. |
386
|
|
|
* |
387
|
|
|
* @param $breadcrumb |
388
|
|
|
* @return $this |
389
|
|
|
*/ |
390
|
|
|
public function setBreadcrumb($breadcrumb) |
391
|
|
|
{ |
392
|
|
|
$this->breadcrumb = $breadcrumb; |
393
|
|
|
|
394
|
|
|
return $this; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Get the HREF attribute. |
399
|
|
|
* |
400
|
|
|
* @param null $path |
401
|
|
|
* @return string |
402
|
|
|
*/ |
403
|
|
|
public function getHref($path = null) |
404
|
|
|
{ |
405
|
|
|
return array_get( |
406
|
|
|
$this->attributes, |
407
|
|
|
'data-href', |
408
|
|
|
array_get($this->attributes, 'href') |
409
|
|
|
) . ($path ? '/' . $path : $path); |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* Return the child sections. |
414
|
|
|
* |
415
|
|
|
* @return SectionCollection |
416
|
|
|
*/ |
417
|
|
|
public function children() |
418
|
|
|
{ |
419
|
|
|
return app(SectionCollection::class)->children($this->getSlug()); |
420
|
|
|
} |
421
|
|
|
} |
422
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.