1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WebHemi. |
4
|
|
|
* |
5
|
|
|
* PHP version 7.1 |
6
|
|
|
* |
7
|
|
|
* @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com) |
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
9
|
|
|
* |
10
|
|
|
* @link http://www.gixx-web.com |
11
|
|
|
*/ |
12
|
|
|
declare(strict_types = 1); |
13
|
|
|
|
14
|
|
|
namespace WebHemi\Data\Entity; |
15
|
|
|
|
16
|
|
|
use WebHemi\DateTime; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class FilesystemEntity |
20
|
|
|
*/ |
21
|
|
|
class FilesystemEntity extends AbstractEntity |
22
|
|
|
{ |
23
|
|
|
public const TYPE_DOCUMENT = 'document'; |
24
|
|
|
public const TYPE_BINARY = 'binary'; |
25
|
|
|
public const TYPE_DIRECTORY = 'directory'; |
26
|
|
|
public const TYPE_SYMLINK = 'symlink'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
protected $container = [ |
32
|
|
|
'id_filesystem' => null, |
33
|
|
|
'fk_application' => null, |
34
|
|
|
'fk_category' => null, |
35
|
|
|
'fk_parent_node' => null, |
36
|
|
|
'fk_filesystem_document' => null, |
37
|
|
|
'fk_filesystem_file' => null, |
38
|
|
|
'fk_filesystem_directory' => null, |
39
|
|
|
'fk_filesystem_link' => null, |
40
|
|
|
'path' => null, |
41
|
|
|
'basename' => null, |
42
|
|
|
'uri' => null, |
43
|
|
|
'title' => null, |
44
|
|
|
'description' => null, |
45
|
|
|
'is_hidden' => null, |
46
|
|
|
'is_read_only' => null, |
47
|
|
|
'is_deleted' => null, |
48
|
|
|
'date_created' => null, |
49
|
|
|
'date_modified' => null, |
50
|
|
|
'date_published' => null, |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return null|string |
55
|
|
|
*/ |
56
|
|
|
public function getType() : ? string |
57
|
|
|
{ |
58
|
|
|
if (!empty($this->container['fk_filesystem_file'])) { |
59
|
|
|
return self::TYPE_BINARY; |
60
|
|
|
} |
61
|
|
|
if (!empty($this->container['fk_filesystem_directory'])) { |
62
|
|
|
return self::TYPE_DIRECTORY; |
63
|
|
|
} |
64
|
|
|
if (!empty($this->container['fk_filesystem_link'])) { |
65
|
|
|
return self::TYPE_SYMLINK; |
66
|
|
|
} |
67
|
|
|
return self::TYPE_DOCUMENT; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param int $identifier |
72
|
|
|
* @return FilesystemEntity |
73
|
|
|
*/ |
74
|
|
|
public function setFilesystemId(int $identifier) : FilesystemEntity |
75
|
|
|
{ |
76
|
|
|
$this->container['id_filesystem'] = $identifier; |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return int|null |
83
|
|
|
*/ |
84
|
|
|
public function getFilesystemId() : ? int |
85
|
|
|
{ |
86
|
|
|
return !is_null($this->container['id_filesystem']) |
87
|
|
|
? (int) $this->container['id_filesystem'] |
88
|
|
|
: null; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param int $applicationIdentifier |
93
|
|
|
* @return FilesystemEntity |
94
|
|
|
*/ |
95
|
|
|
public function setApplicationId(int $applicationIdentifier) : FilesystemEntity |
96
|
|
|
{ |
97
|
|
|
$this->container['fk_application'] = $applicationIdentifier; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return int|null |
104
|
|
|
*/ |
105
|
|
|
public function getApplicationId() : ? int |
106
|
|
|
{ |
107
|
|
|
return !is_null($this->container['fk_application']) |
108
|
|
|
? (int) $this->container['fk_application'] |
109
|
|
|
: null; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param int $categoryIdentifier |
114
|
|
|
* @return FilesystemEntity |
115
|
|
|
*/ |
116
|
|
|
public function setCategoryId(int $categoryIdentifier) : FilesystemEntity |
117
|
|
|
{ |
118
|
|
|
$this->container['fk_category'] = $categoryIdentifier; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return int|null |
125
|
|
|
*/ |
126
|
|
|
public function getCategoryId() : ? int |
127
|
|
|
{ |
128
|
|
|
return !is_null($this->container['fk_category']) |
129
|
|
|
? (int) $this->container['fk_category'] |
130
|
|
|
: null; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param int $parentNodeIdentifier |
135
|
|
|
* @return FilesystemEntity |
136
|
|
|
*/ |
137
|
|
|
public function setParentNodeId(int $parentNodeIdentifier) : FilesystemEntity |
138
|
|
|
{ |
139
|
|
|
$this->container['fk_parent_node'] = $parentNodeIdentifier; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return int|null |
146
|
|
|
*/ |
147
|
|
|
public function getParentNodeId() : ? int |
148
|
|
|
{ |
149
|
|
|
return !is_null($this->container['fk_parent_node']) |
150
|
|
|
? (int) $this->container['fk_parent_node'] |
151
|
|
|
: null; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param int $documentIdentifier |
156
|
|
|
* @return FilesystemEntity |
157
|
|
|
*/ |
158
|
|
|
public function setFilesystemDocumentId(int $documentIdentifier) : FilesystemEntity |
159
|
|
|
{ |
160
|
|
|
$this->container['fk_filesystem_document'] = $documentIdentifier; |
161
|
|
|
|
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return int|null |
167
|
|
|
*/ |
168
|
|
|
public function getFilesystemDocumentId() : ? int |
169
|
|
|
{ |
170
|
|
|
return !is_null($this->container['fk_filesystem_document']) |
171
|
|
|
? (int) $this->container['fk_filesystem_document'] |
172
|
|
|
: null; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param int $fileIdentifier |
177
|
|
|
* @return FilesystemEntity |
178
|
|
|
*/ |
179
|
|
|
public function setFilesystemFileId(int $fileIdentifier) : FilesystemEntity |
180
|
|
|
{ |
181
|
|
|
$this->container['fk_filesystem_file'] = $fileIdentifier; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return int|null |
188
|
|
|
*/ |
189
|
|
|
public function getFilesystemFileId() : ? int |
190
|
|
|
{ |
191
|
|
|
return !is_null($this->container['fk_filesystem_file']) |
192
|
|
|
? (int) $this->container['fk_filesystem_file'] |
193
|
|
|
: null; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param int $directoryIdentifier |
198
|
|
|
* @return FilesystemEntity |
199
|
|
|
*/ |
200
|
|
|
public function setFilesystemDirectoryId(int $directoryIdentifier) : FilesystemEntity |
201
|
|
|
{ |
202
|
|
|
$this->container['fk_filesystem_directory'] = $directoryIdentifier; |
203
|
|
|
|
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return int|null |
209
|
|
|
*/ |
210
|
|
|
public function getFilesystemDirectoryId() : ? int |
211
|
|
|
{ |
212
|
|
|
return !is_null($this->container['fk_filesystem_directory']) |
213
|
|
|
? (int) $this->container['fk_filesystem_directory'] |
214
|
|
|
: null; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @param int $linkIdentifier |
219
|
|
|
* @return FilesystemEntity |
220
|
|
|
*/ |
221
|
|
|
public function setFilesystemLinkId(int $linkIdentifier) : FilesystemEntity |
222
|
|
|
{ |
223
|
|
|
$this->container['fk_filesystem_link'] = $linkIdentifier; |
224
|
|
|
|
225
|
|
|
return $this; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return int|null |
230
|
|
|
*/ |
231
|
|
|
public function getFilesystemLinkId() : ? int |
232
|
|
|
{ |
233
|
|
|
return !is_null($this->container['fk_filesystem_link']) |
234
|
|
|
? (int) $this->container['fk_filesystem_link'] |
235
|
|
|
: null; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @param string $path |
240
|
|
|
* @return FilesystemEntity |
241
|
|
|
*/ |
242
|
|
|
public function setPath(string $path) : FilesystemEntity |
243
|
|
|
{ |
244
|
|
|
$this->container['path'] = $path; |
245
|
|
|
|
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return null|string |
251
|
|
|
*/ |
252
|
|
|
public function getPath() : ? string |
253
|
|
|
{ |
254
|
|
|
return $this->container['path']; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @param string $baseName |
259
|
|
|
* @return FilesystemEntity |
260
|
|
|
*/ |
261
|
|
|
public function setBaseName(string $baseName) : FilesystemEntity |
262
|
|
|
{ |
263
|
|
|
$this->container['basename'] = $baseName; |
264
|
|
|
|
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return null|string |
270
|
|
|
*/ |
271
|
|
|
public function getBaseName() : ? string |
272
|
|
|
{ |
273
|
|
|
return $this->container['basename']; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param string $uri |
278
|
|
|
* @return FilesystemEntity |
279
|
|
|
*/ |
280
|
|
|
public function setUri(string $uri) : FilesystemEntity |
281
|
|
|
{ |
282
|
|
|
$this->container['uri'] = $uri; |
283
|
|
|
|
284
|
|
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return null|string |
289
|
|
|
*/ |
290
|
|
|
public function getUri() : ? string |
291
|
|
|
{ |
292
|
|
|
return $this->container['uri']; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @param string $title |
297
|
|
|
* @return FilesystemEntity |
298
|
|
|
*/ |
299
|
|
|
public function setTitle(string $title) : FilesystemEntity |
300
|
|
|
{ |
301
|
|
|
$this->container['title'] = $title; |
302
|
|
|
|
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @return null|string |
308
|
|
|
*/ |
309
|
|
|
public function getTitle() : ? string |
310
|
|
|
{ |
311
|
|
|
return $this->container['title']; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* @param string $description |
316
|
|
|
* @return FilesystemEntity |
317
|
|
|
*/ |
318
|
|
|
public function setDescription(string $description) : FilesystemEntity |
319
|
|
|
{ |
320
|
|
|
$this->container['description'] = $description; |
321
|
|
|
|
322
|
|
|
return $this; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @return null|string |
327
|
|
|
*/ |
328
|
|
|
public function getDescription() : ? string |
329
|
|
|
{ |
330
|
|
|
return $this->container['description']; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* @param bool $isHidden |
335
|
|
|
* @return FilesystemEntity |
336
|
|
|
*/ |
337
|
|
|
public function setIsHidden(bool $isHidden) : FilesystemEntity |
338
|
|
|
{ |
339
|
|
|
$this->container['is_hidden'] = $isHidden ? 1 : 0; |
340
|
|
|
|
341
|
|
|
return $this; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* @return bool |
346
|
|
|
*/ |
347
|
|
|
public function getIsHidden() : bool |
348
|
|
|
{ |
349
|
|
|
return !empty($this->container['is_hidden']); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @param bool $isReadonly |
354
|
|
|
* @return FilesystemEntity |
355
|
|
|
*/ |
356
|
|
|
public function setIsReadOnly(bool $isReadonly) : FilesystemEntity |
357
|
|
|
{ |
358
|
|
|
$this->container['is_read_only'] = $isReadonly ? 1 : 0; |
359
|
|
|
|
360
|
|
|
return $this; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @return bool |
365
|
|
|
*/ |
366
|
|
|
public function getIsReadOnly() : bool |
367
|
|
|
{ |
368
|
|
|
return !empty($this->container['is_read_only']); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @param bool $isDeleted |
373
|
|
|
* @return FilesystemEntity |
374
|
|
|
*/ |
375
|
|
|
public function setIsDeleted(bool $isDeleted) : FilesystemEntity |
376
|
|
|
{ |
377
|
|
|
$this->container['is_deleted'] = $isDeleted ? 1 : 0; |
378
|
|
|
|
379
|
|
|
return $this; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @return bool |
384
|
|
|
*/ |
385
|
|
|
public function getIsDeleted() : bool |
386
|
|
|
{ |
387
|
|
|
return !empty($this->container['is_deleted']); |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
/** |
391
|
|
|
* @param DateTime $dateTime |
392
|
|
|
* @return FilesystemEntity |
393
|
|
|
*/ |
394
|
|
|
public function setDateCreated(DateTime $dateTime) : FilesystemEntity |
395
|
|
|
{ |
396
|
|
|
$this->container['date_created'] = $dateTime->format('Y-m-d H:i:s'); |
397
|
|
|
|
398
|
|
|
return $this; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* @return null|DateTime |
403
|
|
|
*/ |
404
|
|
|
public function getDateCreated() : ? DateTime |
405
|
|
|
{ |
406
|
|
|
return !empty($this->container['date_created']) |
407
|
|
|
? new DateTime($this->container['date_created']) |
408
|
|
|
: null; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* @param DateTime $dateTime |
413
|
|
|
* @return FilesystemEntity |
414
|
|
|
*/ |
415
|
|
|
public function setDateModified(DateTime $dateTime) : FilesystemEntity |
416
|
|
|
{ |
417
|
|
|
$this->container['date_modified'] = $dateTime->format('Y-m-d H:i:s'); |
418
|
|
|
|
419
|
|
|
return $this; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* @return null|DateTime |
424
|
|
|
*/ |
425
|
|
|
public function getDateModified() : ? DateTime |
426
|
|
|
{ |
427
|
|
|
return !empty($this->container['date_modified']) |
428
|
|
|
? new DateTime($this->container['date_modified']) |
429
|
|
|
: null; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* @param DateTime $dateTime |
434
|
|
|
* @return FilesystemEntity |
435
|
|
|
*/ |
436
|
|
|
public function setDatePublished(DateTime $dateTime) : FilesystemEntity |
437
|
|
|
{ |
438
|
|
|
$this->container['date_published'] = $dateTime->format('Y-m-d H:i:s'); |
439
|
|
|
|
440
|
|
|
return $this; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* @return null|DateTime |
445
|
|
|
*/ |
446
|
|
|
public function getDatePublished() : ? DateTime |
447
|
|
|
{ |
448
|
|
|
return !empty($this->container['date_published']) |
449
|
|
|
? new DateTime($this->container['date_published']) |
450
|
|
|
: null; |
451
|
|
|
} |
452
|
|
|
} |
453
|
|
|
|