|
1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation; |
|
2
|
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation\Contract\NavigationLinkInterface; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class NavigationLink |
|
7
|
|
|
* |
|
8
|
|
|
* @link http://pyrocms.com/ |
|
9
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
|
10
|
|
|
* @author Ryan Thompson <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class NavigationLink implements NavigationLinkInterface |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The links slug. |
|
17
|
|
|
* |
|
18
|
|
|
* @var null|string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $slug = null; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The link icon. |
|
24
|
|
|
* |
|
25
|
|
|
* @var null|string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $icon = null; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* The links title. |
|
31
|
|
|
* |
|
32
|
|
|
* @var null|string |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $title = null; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* The class. |
|
38
|
|
|
* |
|
39
|
|
|
* @var null|string |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $class = null; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* The active flag. |
|
45
|
|
|
* |
|
46
|
|
|
* @var bool |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $active = false; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* The favorite flag. |
|
52
|
|
|
* |
|
53
|
|
|
* @var bool |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $favorite = false; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* The links attributes. |
|
59
|
|
|
* |
|
60
|
|
|
* @var array |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $attributes = []; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* The links permission. |
|
66
|
|
|
* |
|
67
|
|
|
* @var null|string |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $permission = null; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* The links breadcrumb. |
|
73
|
|
|
* |
|
74
|
|
|
* @var null|string |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $breadcrumb = null; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Get the slug. |
|
80
|
|
|
* |
|
81
|
|
|
* @return null|string |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getSlug() |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->slug; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Set the slug. |
|
90
|
|
|
* |
|
91
|
|
|
* @param $slug |
|
92
|
|
|
* @return $this |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setSlug($slug) |
|
95
|
|
|
{ |
|
96
|
|
|
$this->slug = $slug; |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Get the icon. |
|
103
|
|
|
* |
|
104
|
|
|
* @return null|string |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getIcon() |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->icon; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Set the icon. |
|
113
|
|
|
* |
|
114
|
|
|
* @param $icon |
|
115
|
|
|
* @return $this |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setIcon($icon) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->icon = $icon; |
|
120
|
|
|
|
|
121
|
|
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Get the title. |
|
126
|
|
|
* |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getTitle() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->title; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Set the title. |
|
136
|
|
|
* |
|
137
|
|
|
* @param string $title |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setTitle($title) |
|
140
|
|
|
{ |
|
141
|
|
|
$this->title = $title; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Get the class. |
|
146
|
|
|
* |
|
147
|
|
|
* @return string |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getClass() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->class; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Set the class. |
|
156
|
|
|
* |
|
157
|
|
|
* @param $class |
|
158
|
|
|
* @return $this |
|
159
|
|
|
*/ |
|
160
|
|
|
public function setClass($class) |
|
161
|
|
|
{ |
|
162
|
|
|
$this->class = $class; |
|
163
|
|
|
|
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Get the active flag. |
|
169
|
|
|
* |
|
170
|
|
|
* @return boolean |
|
171
|
|
|
*/ |
|
172
|
|
|
public function isActive() |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->active; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Set the active flag. |
|
179
|
|
|
* |
|
180
|
|
|
* @param boolean $active |
|
181
|
|
|
*/ |
|
182
|
|
|
public function setActive($active) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->active = $active; |
|
185
|
|
|
|
|
186
|
|
|
return $this; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Get the favorite flag. |
|
191
|
|
|
* |
|
192
|
|
|
* @return boolean |
|
193
|
|
|
*/ |
|
194
|
|
|
public function isFavorite() |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->favorite; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* Set the favorite flag. |
|
201
|
|
|
* |
|
202
|
|
|
* @param boolean $favorite |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setFavorite($favorite) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->favorite = $favorite; |
|
207
|
|
|
|
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Get the attributes. |
|
213
|
|
|
* |
|
214
|
|
|
* @return array |
|
215
|
|
|
*/ |
|
216
|
|
|
public function getAttributes() |
|
217
|
|
|
{ |
|
218
|
|
|
return $this->attributes; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Set the attributes. |
|
223
|
|
|
* |
|
224
|
|
|
* @param array $attributes |
|
225
|
|
|
*/ |
|
226
|
|
|
public function setAttributes(array $attributes) |
|
227
|
|
|
{ |
|
228
|
|
|
$this->attributes = $attributes; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* Get the permission. |
|
233
|
|
|
* |
|
234
|
|
|
* @return null|string |
|
235
|
|
|
*/ |
|
236
|
|
|
public function getPermission() |
|
237
|
|
|
{ |
|
238
|
|
|
return $this->permission; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* Set the permission. |
|
243
|
|
|
* |
|
244
|
|
|
* @param $permission |
|
245
|
|
|
* @return $this |
|
246
|
|
|
*/ |
|
247
|
|
|
public function setPermission($permission) |
|
248
|
|
|
{ |
|
249
|
|
|
$this->permission = $permission; |
|
250
|
|
|
|
|
251
|
|
|
return $this; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* Get the breadcrumb. |
|
256
|
|
|
* |
|
257
|
|
|
* @return null|string |
|
258
|
|
|
*/ |
|
259
|
|
|
public function getBreadcrumb() |
|
260
|
|
|
{ |
|
261
|
|
|
return $this->breadcrumb; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Set the breadcrumb. |
|
266
|
|
|
* |
|
267
|
|
|
* @param $breadcrumb |
|
268
|
|
|
* @return $this |
|
269
|
|
|
*/ |
|
270
|
|
|
public function setBreadcrumb($breadcrumb) |
|
271
|
|
|
{ |
|
272
|
|
|
$this->breadcrumb = $breadcrumb; |
|
273
|
|
|
|
|
274
|
|
|
return $this; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* Get the HREF attribute. |
|
279
|
|
|
* |
|
280
|
|
|
* @param null $path |
|
281
|
|
|
* @return string |
|
282
|
|
|
*/ |
|
283
|
|
|
public function getHref($path = null) |
|
284
|
|
|
{ |
|
285
|
|
|
return array_get($this->attributes, 'href') . ($path ? '/' . $path : $path); |
|
286
|
|
|
} |
|
287
|
|
|
} |
|
288
|
|
|
|