|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace luya\web\jsonld; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* JsonLd - Thing trait |
|
7
|
|
|
* |
|
8
|
|
|
* @author Alex Schmid |
|
9
|
|
|
* @since 1.0.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
trait ThingTrait |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. |
|
15
|
|
|
* This is a relationship between something and a class that the thing is in. |
|
16
|
|
|
* |
|
17
|
|
|
* @var URL |
|
18
|
|
|
*/ |
|
19
|
|
|
private $_additionalType; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @return URL |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getAdditionalType() |
|
25
|
|
|
{ |
|
26
|
|
|
return $this->_additionalType; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param URL $additionalType |
|
31
|
|
|
* @return Thing |
|
32
|
|
|
*/ |
|
33
|
|
|
public function setAdditionalType(URL $additionalType) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->_additionalType = $additionalType; |
|
36
|
|
|
return $this; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* An alias for the item |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $_alternateName; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getAlternateName() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->_alternateName; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $alternateName |
|
56
|
|
|
* @return Thing |
|
57
|
|
|
*/ |
|
58
|
|
|
public function setAlternateName(string $alternateName) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->_alternateName = $alternateName; |
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* A description of the item. |
|
66
|
|
|
* |
|
67
|
|
|
* @var string |
|
68
|
|
|
*/ |
|
69
|
|
|
private $_description; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getDescription() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->_description; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param string $description |
|
81
|
|
|
* @return Thing |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setDescription(string $description) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->_description = $description; |
|
86
|
|
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* A sub property of description. A short description of the item used to disambiguate from other, similar items. |
|
91
|
|
|
* Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation. |
|
92
|
|
|
* |
|
93
|
|
|
* @var string |
|
94
|
|
|
*/ |
|
95
|
|
|
private $_disambiguatingDescription; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return string |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getDisambiguatingDescription() |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->_disambiguatingDescription; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param string $disambiguatingDescription |
|
107
|
|
|
* @return Thing |
|
108
|
|
|
*/ |
|
109
|
|
|
public function setDisambiguatingDescription(string $disambiguatingDescription) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->_disambiguatingDescription = $disambiguatingDescription; |
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details. |
|
117
|
|
|
* |
|
118
|
|
|
* @var PropertyValue|string|URL |
|
119
|
|
|
*/ |
|
120
|
|
|
private $_identifier; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return PropertyValue|URL|string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getIdentifier() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->_identifier; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param PropertyValue|URL|string $identifier |
|
132
|
|
|
* @return Thing |
|
133
|
|
|
*/ |
|
134
|
|
|
public function setIdentifier($identifier) |
|
135
|
|
|
{ |
|
136
|
|
|
$this->_identifier = $identifier; |
|
137
|
|
|
return $this; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* An image of the item. |
|
142
|
|
|
* This can be a URL or a fully described ImageObject. |
|
143
|
|
|
* |
|
144
|
|
|
* @var ImageObject|URL |
|
145
|
|
|
*/ |
|
146
|
|
|
private $_image; |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @return ImageObject|URL |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getImage() |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->_image; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param ImageObject|URL $image |
|
158
|
|
|
* @return Thing |
|
159
|
|
|
*/ |
|
160
|
|
|
public function setImage($image) |
|
161
|
|
|
{ |
|
162
|
|
|
$this->_image = $image; |
|
163
|
|
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Indicates a page (or other CreativeWork) for which this thing is the main entity being described. |
|
168
|
|
|
* Inverse property: mainEntity. |
|
169
|
|
|
* |
|
170
|
|
|
* @var CreativeWork|URL |
|
171
|
|
|
*/ |
|
172
|
|
|
private $_mainEntityOfPage; |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @return CreativeWork|URL |
|
176
|
|
|
*/ |
|
177
|
|
|
public function getMainEntityOfPage() |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->_mainEntityOfPage; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* @param CreativeWork|URL $mainEntityOfPage |
|
184
|
|
|
* @return Thing |
|
185
|
|
|
*/ |
|
186
|
|
|
public function setMainEntityOfPage($mainEntityOfPage) |
|
187
|
|
|
{ |
|
188
|
|
|
$this->_mainEntityOfPage = $mainEntityOfPage; |
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* The name of the item. |
|
194
|
|
|
* |
|
195
|
|
|
* @var string |
|
196
|
|
|
*/ |
|
197
|
|
|
private $_name; |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @return string |
|
201
|
|
|
*/ |
|
202
|
|
|
public function getName() |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->_name; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @param string $name |
|
209
|
|
|
* @return Thing |
|
210
|
|
|
*/ |
|
211
|
|
|
public function setName(string $name) |
|
212
|
|
|
{ |
|
213
|
|
|
$this->_name = $name; |
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Indicates a potential Action, which describes an idealized action in which this thing would play an 'object' role. |
|
219
|
|
|
* |
|
220
|
|
|
* @var Action |
|
221
|
|
|
*/ |
|
222
|
|
|
private $_potentialAction; |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* @return Action |
|
226
|
|
|
*/ |
|
227
|
|
|
public function getPotentialAction() |
|
228
|
|
|
{ |
|
229
|
|
|
return $this->_potentialAction; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @param Action $potentialAction |
|
234
|
|
|
* @return Thing |
|
235
|
|
|
*/ |
|
236
|
|
|
public function setPotentialAction(Action $potentialAction) |
|
237
|
|
|
{ |
|
238
|
|
|
$this->_potentialAction = $potentialAction; |
|
239
|
|
|
return $this; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* URL of a reference Web page that unambiguously indicates the item's identity. |
|
244
|
|
|
* E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website. |
|
245
|
|
|
* |
|
246
|
|
|
* @var URL |
|
247
|
|
|
*/ |
|
248
|
|
|
private $_sameAs; |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* @return URL |
|
252
|
|
|
*/ |
|
253
|
|
|
public function getSameAs() |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->_sameAs; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @param URL $sameAs |
|
260
|
|
|
* @return Thing |
|
261
|
|
|
*/ |
|
262
|
|
|
public function setSameAs(URL $sameAs) |
|
263
|
|
|
{ |
|
264
|
|
|
$this->_sameAs = $sameAs; |
|
265
|
|
|
return $this; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* A CreativeWork or Event about this Thing. |
|
270
|
|
|
* Inverse property: about. |
|
271
|
|
|
* |
|
272
|
|
|
* @var CreativeWork|Event |
|
273
|
|
|
*/ |
|
274
|
|
|
private $_subjectOf; |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* @return CreativeWork|Event |
|
278
|
|
|
*/ |
|
279
|
|
|
public function getSubjectOf() |
|
280
|
|
|
{ |
|
281
|
|
|
return $this->_subjectOf; |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* @param CreativeWork|Event $subjectOf |
|
286
|
|
|
* @return Thing |
|
287
|
|
|
*/ |
|
288
|
|
|
public function setSubjectOf($subjectOf) |
|
289
|
|
|
{ |
|
290
|
|
|
$this->_subjectOf = $subjectOf; |
|
291
|
|
|
return $this; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
/** |
|
295
|
|
|
* URL of the item. |
|
296
|
|
|
* |
|
297
|
|
|
* @var URL |
|
298
|
|
|
*/ |
|
299
|
|
|
private $_url; |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* @return URL |
|
303
|
|
|
*/ |
|
304
|
|
|
public function getUrl() |
|
305
|
|
|
{ |
|
306
|
|
|
return $this->_url; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* @param URL $url |
|
311
|
|
|
* @return Thing |
|
312
|
|
|
*/ |
|
313
|
|
|
public function setUrl(URL $url) |
|
314
|
|
|
{ |
|
315
|
|
|
$this->_url = $url; |
|
316
|
|
|
return $this; |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
/** |
|
320
|
|
|
* Return the fields |
|
321
|
|
|
*/ |
|
322
|
|
|
public function fields() |
|
323
|
|
|
{ |
|
324
|
|
|
return ['additionalType', 'alternateName', 'description', 'disambiguatingDescription', 'identifier', 'image', 'mainEntityOfPage', 'name', 'potentialAction', 'sameAs', 'subjectOf', 'url']; |
|
325
|
|
|
} |
|
326
|
|
|
} |