1 | <?php |
||
55 | class SystemProperties extends AbstractProperties |
||
56 | { |
||
57 | /** |
||
58 | * Collection name |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | const COLLECTION = 'system'; |
||
63 | /** |
||
64 | * ID property |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | const PROPERTY_ID = 'id'; |
||
69 | /** |
||
70 | * Type property |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | const PROPERTY_TYPE = 'type'; |
||
75 | /** |
||
76 | * Revision property |
||
77 | * |
||
78 | * @var string |
||
79 | */ |
||
80 | const PROPERTY_REVISION = 'revision'; |
||
81 | /** |
||
82 | * Created property |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | const PROPERTY_CREATED = 'created'; |
||
87 | /** |
||
88 | * Published property |
||
89 | * |
||
90 | * @var string |
||
91 | */ |
||
92 | const PROPERTY_PUBLISHED = 'published'; |
||
93 | /** |
||
94 | * LocationProperties property |
||
95 | * |
||
96 | * @var string |
||
97 | */ |
||
98 | const PROPERTY_LOCATION = 'location'; |
||
99 | /** |
||
100 | * Hash property |
||
101 | * |
||
102 | * @var string |
||
103 | */ |
||
104 | const PROPERTY_HASH = 'hash'; |
||
105 | /** |
||
106 | * Object ID (constant throughout revisions) |
||
107 | * |
||
108 | * @var Id |
||
109 | */ |
||
110 | protected $uid = null; |
||
111 | /** |
||
112 | * Object type (constant throughout revisions) |
||
113 | * |
||
114 | * @var Type |
||
115 | */ |
||
116 | protected $type = null; |
||
117 | /** |
||
118 | * Object revision |
||
119 | * |
||
120 | * @var Revision |
||
121 | */ |
||
122 | protected $revision = null; |
||
123 | /** |
||
124 | * Creation date of this revision |
||
125 | * |
||
126 | * @var \DateTimeImmutable |
||
127 | */ |
||
128 | protected $created = null; |
||
129 | /** |
||
130 | * Publication date of this revision |
||
131 | * |
||
132 | * @var \DateTimeImmutable |
||
133 | */ |
||
134 | protected $published = null; |
||
135 | /** |
||
136 | * Location |
||
137 | * |
||
138 | * @var LocationProperties |
||
139 | */ |
||
140 | protected $location = null; |
||
141 | /** |
||
142 | * Object hash of this revision |
||
143 | * |
||
144 | * @var string |
||
145 | */ |
||
146 | protected $hash = ''; |
||
147 | |||
148 | /** |
||
149 | * System properties constructor |
||
150 | * |
||
151 | * @param array $data Property data |
||
152 | * @param ObjectInterface $object Owner object |
||
153 | */ |
||
154 | 23 | public function __construct(array $data, ObjectInterface $object) |
|
207 | |||
208 | /** |
||
209 | * Return the object ID |
||
210 | * |
||
211 | * @return Id Object ID |
||
212 | */ |
||
213 | 5 | public function getId() |
|
217 | |||
218 | /** |
||
219 | * Return the object type |
||
220 | * |
||
221 | * @return Type Object type |
||
222 | */ |
||
223 | 1 | public function getType() |
|
227 | |||
228 | /** |
||
229 | * Return the object revision |
||
230 | * |
||
231 | * @return Revision Object revision |
||
232 | */ |
||
233 | 20 | public function getRevision() |
|
237 | |||
238 | /** |
||
239 | * Return the object draft mode |
||
240 | * |
||
241 | * @return boolean Object draft mode |
||
242 | */ |
||
243 | 4 | public function isDraft() |
|
247 | |||
248 | /** |
||
249 | * Return the creation date & time of this revision |
||
250 | * |
||
251 | * @return \DateTimeImmutable Creation date & time |
||
252 | */ |
||
253 | 1 | public function getCreated() |
|
257 | |||
258 | /** |
||
259 | * Return the publication date & time of this revision |
||
260 | * |
||
261 | * @return \DateTimeImmutable|null Publication date & time |
||
262 | */ |
||
263 | 1 | public function getPublished() |
|
267 | |||
268 | /** |
||
269 | * Return the latitude |
||
270 | * |
||
271 | * @return float Latitude |
||
272 | */ |
||
273 | 1 | public function getLatitude() |
|
277 | |||
278 | /** |
||
279 | * Set the latitude |
||
280 | * |
||
281 | * @param float $latitude Latitude |
||
282 | * @return SystemProperties Self reference |
||
283 | */ |
||
284 | 1 | public function setLatitude($latitude) |
|
291 | |||
292 | /** |
||
293 | * Return the longitude |
||
294 | * |
||
295 | * @return float Longitude |
||
296 | */ |
||
297 | 1 | public function getLongitude() |
|
301 | |||
302 | /** |
||
303 | * Set the longitude |
||
304 | * |
||
305 | * @param float $longitude Longitude |
||
306 | * @return SystemProperties Self reference |
||
307 | */ |
||
308 | 1 | public function setLongitude($longitude) |
|
315 | |||
316 | /** |
||
317 | * Return the elevation |
||
318 | * |
||
319 | * @return float Elevation |
||
320 | */ |
||
321 | public function getElevation() |
||
325 | |||
326 | /** |
||
327 | * Set the elevation |
||
328 | * |
||
329 | * @param float $elevation |
||
330 | * @return SystemProperties Self reference |
||
331 | */ |
||
332 | 1 | public function setElevation($elevation) |
|
339 | |||
340 | /** |
||
341 | * Return the object hash of this revision |
||
342 | * |
||
343 | * @return string Object hash |
||
344 | */ |
||
345 | 1 | public function getHash() |
|
349 | |||
350 | /** |
||
351 | * Derive draft system properties |
||
352 | * |
||
353 | * @param Revision $draftRevision Draft revision |
||
354 | * @return SystemProperties Draft system properties |
||
355 | */ |
||
356 | 3 | public function createDraft(Revision $draftRevision) |
|
368 | |||
369 | /** |
||
370 | * Indicate that the object got published |
||
371 | * |
||
372 | * @return SystemProperties System properties |
||
373 | * @throws RuntimeException If the object is already published |
||
374 | */ |
||
375 | 2 | public function publish() |
|
389 | |||
390 | /** |
||
391 | * Return the property values as array |
||
392 | * |
||
393 | * @return array Property values |
||
394 | */ |
||
395 | 5 | public function toArray() |
|
408 | |||
409 | /** |
||
410 | * Test if the object hash is a valid sha1 value |
||
411 | * |
||
412 | * @return bool The object hash is a valid sha1 value |
||
413 | */ |
||
414 | protected function hasValidHash() |
||
418 | } |
||
419 |