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\Storage; |
15
|
|
|
|
16
|
|
|
use WebHemi\Data\Entity\EntitySet; |
17
|
|
|
use WebHemi\Data\Entity\FilesystemCategoryEntity; |
18
|
|
|
use WebHemi\Data\Entity\FilesystemDirectoryEntity; |
19
|
|
|
use WebHemi\Data\Entity\FilesystemDirectoryDataEntity; |
20
|
|
|
use WebHemi\Data\Entity\FilesystemDocumentEntity; |
21
|
|
|
use WebHemi\Data\Entity\FilesystemEntity; |
22
|
|
|
use WebHemi\Data\Entity\FilesystemMetaEntity; |
23
|
|
|
use WebHemi\Data\Entity\FilesystemPublishedDocumentEntity; |
24
|
|
|
use WebHemi\Data\Entity\FilesystemTagEntity; |
25
|
|
|
use WebHemi\Data\Query\QueryInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class FilesystemStorage. |
29
|
|
|
* |
30
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
31
|
|
|
*/ |
32
|
|
|
class FilesystemStorage extends AbstractStorage |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Returns a set of filesystem data accroding to the application and directory ID. |
36
|
|
|
* |
37
|
|
|
* @param int $applicationId |
38
|
|
|
* @param int $directoryId |
39
|
|
|
* @param int $limit |
40
|
|
|
* @param int $offset |
41
|
|
|
* @return EntitySet |
42
|
|
|
*/ |
43
|
|
|
public function getFilesystemListByApplicationAndDirectory( |
44
|
|
|
int $applicationId, |
45
|
|
|
int $directoryId, |
46
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
47
|
|
|
int $offset = 0 |
48
|
|
|
) : EntitySet { |
49
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
50
|
|
|
|
51
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
52
|
|
|
'getFilesystemListByApplicationAndDirectory', |
53
|
|
|
[ |
54
|
|
|
':idApplication' => $applicationId, |
55
|
|
|
':idDirectory' => $directoryId, |
56
|
|
|
':limit' => $limit, |
57
|
|
|
':offset' => $offset |
58
|
|
|
] |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$entitySet = $this->createEntitySet(); |
62
|
|
|
|
63
|
|
|
foreach ($data as $row) { |
|
|
|
|
64
|
|
|
/** @var FilesystemEntity $entity */ |
65
|
|
|
$entity = $this->createEntity(FilesystemEntity::class, $row); |
66
|
|
|
|
67
|
|
|
if (!empty($entity)) { |
68
|
|
|
$entitySet[] = $entity; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $entitySet; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns filesystem information identified by (unique) ID. |
77
|
|
|
* |
78
|
|
|
* @param int $identifier |
79
|
|
|
* @return null|FilesystemEntity |
80
|
|
|
*/ |
81
|
|
|
public function getFilesystemById(int $identifier) : ? FilesystemEntity |
82
|
|
|
{ |
83
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
84
|
|
|
'getFilesystemById', |
85
|
|
|
[':idFilesystem' => $identifier] |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
/** @var null|FilesystemEntity $entity */ |
89
|
|
|
$entity = $this->createEntity(FilesystemEntity::class, $data[0] ?? []); |
90
|
|
|
|
91
|
|
|
return $entity; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns filesystem information by application, basename and path. |
96
|
|
|
* |
97
|
|
|
* @param int $applicationId |
98
|
|
|
* @param string $path |
99
|
|
|
* @param string $baseName |
100
|
|
|
* @return null|FilesystemEntity |
101
|
|
|
*/ |
102
|
|
|
public function getFilesystemByApplicationAndPath( |
103
|
|
|
int $applicationId, |
104
|
|
|
string $path, |
105
|
|
|
string $baseName |
106
|
|
|
) : ? FilesystemEntity { |
107
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
108
|
|
|
'getFilesystemByApplicationAndPath', |
109
|
|
|
[ |
110
|
|
|
':idApplication' => $applicationId, |
111
|
|
|
':path' => $path, |
112
|
|
|
':baseName' => $baseName |
113
|
|
|
] |
114
|
|
|
); |
115
|
|
|
|
116
|
|
|
/** @var null|FilesystemEntity $entity */ |
117
|
|
|
$entity = $this->createEntity(FilesystemEntity::class, $data[0] ?? []); |
118
|
|
|
|
119
|
|
|
return $entity; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Returns filesystem meta list identified by filesystem ID. |
124
|
|
|
* |
125
|
|
|
* @param int $identifier |
126
|
|
|
* @param int $limit |
127
|
|
|
* @param int $offset |
128
|
|
|
* @return EntitySet |
129
|
|
|
*/ |
130
|
|
|
public function getFilesystemMetaListByFilesystem( |
131
|
|
|
int $identifier, |
132
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
133
|
|
|
int $offset = 0 |
134
|
|
|
) : EntitySet { |
135
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
136
|
|
|
|
137
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
138
|
|
|
'getFilesystemMetaListByFilesystem', |
139
|
|
|
[ |
140
|
|
|
':idFilesystem' => $identifier, |
141
|
|
|
':limit' => $limit, |
142
|
|
|
':offset' => $offset |
143
|
|
|
] |
144
|
|
|
); |
145
|
|
|
|
146
|
|
|
$entitySet = $this->createEntitySet(); |
147
|
|
|
|
148
|
|
|
foreach ($data as $row) { |
|
|
|
|
149
|
|
|
/** @var FilesystemMetaEntity $entity */ |
150
|
|
|
$entity = $this->createEntity(FilesystemMetaEntity::class, $row); |
151
|
|
|
|
152
|
|
|
if (!empty($entity)) { |
153
|
|
|
$entitySet[] = $entity; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
return $entitySet; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Returns a simplified form of the filesystem meta list. |
162
|
|
|
* |
163
|
|
|
* @param int $identifier |
164
|
|
|
* @param int $limit |
165
|
|
|
* @param int $offset |
166
|
|
|
* @return null|array |
167
|
|
|
*/ |
168
|
|
|
public function getSimpleFilesystemMetaListByFilesystem( |
169
|
|
|
int $identifier, |
170
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
171
|
|
|
int $offset = 0 |
172
|
|
|
) : ? array { |
173
|
|
|
$metaInfo = []; |
174
|
|
|
$entitySet = $this->getFilesystemMetaListByFilesystem($identifier, $limit, $offset); |
175
|
|
|
|
176
|
|
|
/** @var FilesystemMetaEntity $filesystemMetaEntity */ |
177
|
|
|
foreach ($entitySet as $filesystemMetaEntity) { |
178
|
|
|
$metaInfo[$filesystemMetaEntity->getMetaKey()] = $filesystemMetaEntity->getMetaData(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return $metaInfo; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Returns the full filesystem document data set. |
186
|
|
|
* |
187
|
|
|
* @param int $limit |
188
|
|
|
* @param int $offset |
189
|
|
|
* @return EntitySet |
190
|
|
|
*/ |
191
|
|
|
public function getFilesystemDocumentList( |
192
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
193
|
|
|
int $offset = 0 |
194
|
|
|
) : EntitySet { |
195
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
196
|
|
|
|
197
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
198
|
|
|
'getFilesystemDocumentList', |
199
|
|
|
[ |
200
|
|
|
':limit' => $limit, |
201
|
|
|
':offset' => $offset |
202
|
|
|
] |
203
|
|
|
); |
204
|
|
|
|
205
|
|
|
$entitySet = $this->createEntitySet(); |
206
|
|
|
|
207
|
|
|
foreach ($data as $row) { |
|
|
|
|
208
|
|
|
/** @var FilesystemDocumentEntity $entity */ |
209
|
|
|
$entity = $this->createEntity(FilesystemDocumentEntity::class, $row); |
210
|
|
|
|
211
|
|
|
if (!empty($entity)) { |
212
|
|
|
$entitySet[] = $entity; |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
return $entitySet; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Returns filesystem document information identified by (unique) ID. |
221
|
|
|
* |
222
|
|
|
* @param int $identifier |
223
|
|
|
* @return null|FilesystemDocumentEntity |
224
|
|
|
*/ |
225
|
|
|
public function getFilesystemDocumentById(int $identifier) : ? FilesystemDocumentEntity |
226
|
|
|
{ |
227
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
228
|
|
|
'getFilesystemDocumentById', |
229
|
|
|
[':idDocument' => $identifier] |
230
|
|
|
); |
231
|
|
|
|
232
|
|
|
/** @var null|FilesystemDocumentEntity $entity */ |
233
|
|
|
$entity = $this->createEntity(FilesystemDocumentEntity::class, $data[0] ?? []); |
234
|
|
|
|
235
|
|
|
return $entity; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Returns published filesystem data along with the document data. |
240
|
|
|
* |
241
|
|
|
* @param int $applicationId |
242
|
|
|
* @param string|null $order |
243
|
|
|
* @param int $limit |
244
|
|
|
* @param int $offset |
245
|
|
|
* @return EntitySet |
246
|
|
|
*/ |
247
|
|
|
public function getFilesystemPublishedDocumentList( |
248
|
|
|
int $applicationId, |
249
|
|
|
string $order = null, |
250
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
251
|
|
|
int $offset = 0 |
252
|
|
|
) : EntitySet { |
253
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
254
|
|
|
|
255
|
|
|
if (empty($order)) { |
256
|
|
|
$order = 'fs.`date_published` DESC'; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
260
|
|
|
'getFilesystemPublishedDocumentList', |
261
|
|
|
[ |
262
|
|
|
':idApplication' => $applicationId, |
263
|
|
|
':orderBy' => $order, |
264
|
|
|
':limit' => $limit, |
265
|
|
|
':offset' => $offset |
266
|
|
|
] |
267
|
|
|
); |
268
|
|
|
|
269
|
|
|
$entitySet = $this->createEntitySet(); |
270
|
|
|
|
271
|
|
|
foreach ($data as $row) { |
|
|
|
|
272
|
|
|
/** @var FilesystemPublishedDocumentEntity $entity */ |
273
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $row); |
274
|
|
|
|
275
|
|
|
if (!empty($entity)) { |
276
|
|
|
$entitySet[] = $entity; |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
return $entitySet; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Returns published filesystem data along with the document data. |
285
|
|
|
* |
286
|
|
|
* @param int $applicationId |
287
|
|
|
* @param int $year |
288
|
|
|
* @param int $month |
289
|
|
|
* @param string|null $order |
290
|
|
|
* @param int $limit |
291
|
|
|
* @param int $offset |
292
|
|
|
* @return EntitySet |
293
|
|
|
*/ |
294
|
|
|
public function getFilesystemPublishedDocumentListByDate( |
295
|
|
|
int $applicationId, |
296
|
|
|
int $year, |
297
|
|
|
int $month, |
298
|
|
|
string $order = null, |
299
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
300
|
|
|
int $offset = 0 |
301
|
|
|
) : EntitySet { |
302
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
303
|
|
|
|
304
|
|
|
if (empty($order)) { |
305
|
|
|
$order = 'fs.`date_published` DESC'; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
309
|
|
|
'getFilesystemPublishedDocumentListByDate', |
310
|
|
|
[ |
311
|
|
|
':idApplication' => $applicationId, |
312
|
|
|
':year' => $year, |
313
|
|
|
':month' => $month, |
314
|
|
|
':orderBy' => $order, |
315
|
|
|
':limit' => $limit, |
316
|
|
|
':offset' => $offset |
317
|
|
|
] |
318
|
|
|
); |
319
|
|
|
|
320
|
|
|
$entitySet = $this->createEntitySet(); |
321
|
|
|
|
322
|
|
|
foreach ($data as $row) { |
|
|
|
|
323
|
|
|
/** @var FilesystemPublishedDocumentEntity $entity */ |
324
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $row); |
325
|
|
|
|
326
|
|
|
if (!empty($entity)) { |
327
|
|
|
$entitySet[] = $entity; |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
return $entitySet; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Returns published filesystem data along with the document data. |
336
|
|
|
* |
337
|
|
|
* @param int $applicationId |
338
|
|
|
* @param int $categoryId |
339
|
|
|
* @param string|null $order |
340
|
|
|
* @param int $limit |
341
|
|
|
* @param int $offset |
342
|
|
|
* @return EntitySet |
343
|
|
|
*/ |
344
|
|
|
public function getFilesystemPublishedDocumentListByCategory( |
345
|
|
|
int $applicationId, |
346
|
|
|
int $categoryId, |
347
|
|
|
string $order = null, |
348
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
349
|
|
|
int $offset = 0 |
350
|
|
|
) : EntitySet { |
351
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
352
|
|
|
|
353
|
|
|
if (empty($order)) { |
354
|
|
|
$order = 'fs.`date_published` DESC'; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
358
|
|
|
'getFilesystemPublishedDocumentListByCategory', |
359
|
|
|
[ |
360
|
|
|
':idApplication' => $applicationId, |
361
|
|
|
':idCategory' => $categoryId, |
362
|
|
|
':orderBy' => $order, |
363
|
|
|
':limit' => $limit, |
364
|
|
|
':offset' => $offset |
365
|
|
|
] |
366
|
|
|
); |
367
|
|
|
|
368
|
|
|
$entitySet = $this->createEntitySet(); |
369
|
|
|
|
370
|
|
|
foreach ($data as $row) { |
|
|
|
|
371
|
|
|
/** @var FilesystemPublishedDocumentEntity $entity */ |
372
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $row); |
373
|
|
|
|
374
|
|
|
if (!empty($entity)) { |
375
|
|
|
$entitySet[] = $entity; |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
return $entitySet; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Returns published filesystem data according to a user ID along with the document data. |
384
|
|
|
* |
385
|
|
|
* @param int $applicationId |
386
|
|
|
* @param int $userId |
387
|
|
|
* @param string|null $order |
388
|
|
|
* @param int $limit |
389
|
|
|
* @param int $offset |
390
|
|
|
* @return EntitySet |
391
|
|
|
*/ |
392
|
|
|
public function getFilesystemPublishedDocumentListByAuthor( |
393
|
|
|
int $applicationId, |
394
|
|
|
int $userId, |
395
|
|
|
string $order = null, |
396
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
397
|
|
|
int $offset = 0 |
398
|
|
|
) : EntitySet { |
399
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
400
|
|
|
|
401
|
|
|
if (empty($order)) { |
402
|
|
|
$order = 'fs.`date_published` DESC'; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
406
|
|
|
'getFilesystemPublishedDocumentListByAuthor', |
407
|
|
|
[ |
408
|
|
|
':idApplication' => $applicationId, |
409
|
|
|
':idUser' => $userId, |
410
|
|
|
':orderBy' => $order, |
411
|
|
|
':limit' => $limit, |
412
|
|
|
':offset' => $offset |
413
|
|
|
] |
414
|
|
|
); |
415
|
|
|
|
416
|
|
|
$entitySet = $this->createEntitySet(); |
417
|
|
|
|
418
|
|
|
foreach ($data as $row) { |
|
|
|
|
419
|
|
|
/** @var FilesystemPublishedDocumentEntity $entity */ |
420
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $row); |
421
|
|
|
|
422
|
|
|
if (!empty($entity)) { |
423
|
|
|
$entitySet[] = $entity; |
424
|
|
|
} |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
return $entitySet; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Returns published filesystem data according to a tag ID along with the document data. |
432
|
|
|
* |
433
|
|
|
* @param int $applicationId |
434
|
|
|
* @param int $tagId |
435
|
|
|
* @param string|null $order |
436
|
|
|
* @param int $limit |
437
|
|
|
* @param int $offset |
438
|
|
|
* @return EntitySet |
439
|
|
|
*/ |
440
|
|
|
public function getFilesystemPublishedDocumentListByTag( |
441
|
|
|
int $applicationId, |
442
|
|
|
int $tagId, |
443
|
|
|
string $order = null, |
444
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
445
|
|
|
int $offset = 0 |
446
|
|
|
) : EntitySet { |
447
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
448
|
|
|
|
449
|
|
|
if (empty($order)) { |
450
|
|
|
$order = 'fs.`date_published` DESC'; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
454
|
|
|
'getFilesystemPublishedDocumentListByTag', |
455
|
|
|
[ |
456
|
|
|
':idApplication' => $applicationId, |
457
|
|
|
':idTag' => $tagId, |
458
|
|
|
':orderBy' => $order, |
459
|
|
|
':limit' => $limit, |
460
|
|
|
':offset' => $offset |
461
|
|
|
] |
462
|
|
|
); |
463
|
|
|
|
464
|
|
|
$entitySet = $this->createEntitySet(); |
465
|
|
|
|
466
|
|
|
foreach ($data as $row) { |
|
|
|
|
467
|
|
|
/** @var FilesystemPublishedDocumentEntity $entity */ |
468
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $row); |
469
|
|
|
|
470
|
|
|
if (!empty($entity)) { |
471
|
|
|
$entitySet[] = $entity; |
472
|
|
|
} |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
return $entitySet; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Returns filesystem information by application, basename and path. |
480
|
|
|
* |
481
|
|
|
* @param int $applicationId |
482
|
|
|
* @param string $path |
483
|
|
|
* @param string $baseName |
484
|
|
|
* @return null|FilesystemPublishedDocumentEntity |
485
|
|
|
*/ |
486
|
|
|
public function getFilesystemPublishedDocumentByApplicationAndPath( |
487
|
|
|
int $applicationId, |
488
|
|
|
string $path, |
489
|
|
|
string $baseName |
490
|
|
|
) : ? FilesystemPublishedDocumentEntity { |
491
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
492
|
|
|
'getFilesystemPublishedDocumentByApplicationAndPath', |
493
|
|
|
[ |
494
|
|
|
':idApplication' => $applicationId, |
495
|
|
|
':path' => $path, |
496
|
|
|
':baseName' => $baseName |
497
|
|
|
] |
498
|
|
|
); |
499
|
|
|
|
500
|
|
|
/** @var null|FilesystemPublishedDocumentEntity $entity */ |
501
|
|
|
$entity = $this->createEntity(FilesystemPublishedDocumentEntity::class, $data[0] ?? []); |
502
|
|
|
|
503
|
|
|
return $entity; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
/** |
507
|
|
|
* Returns a simplified list of publication dates. |
508
|
|
|
* |
509
|
|
|
* @param int $applicationId |
510
|
|
|
* @param int $limit |
511
|
|
|
* @param int $offset |
512
|
|
|
* @return array |
513
|
|
|
*/ |
514
|
|
|
public function getFilesystemPublishedDocumentDateList( |
515
|
|
|
int $applicationId, |
516
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
517
|
|
|
int $offset = 0 |
518
|
|
|
) : array { |
519
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
520
|
|
|
'getFilesystemPublishedDocumentDateList', |
521
|
|
|
[ |
522
|
|
|
':idApplication' => $applicationId, |
523
|
|
|
':limit' => $limit, |
524
|
|
|
':offset' => $offset |
525
|
|
|
] |
526
|
|
|
); |
527
|
|
|
|
528
|
|
|
return $data ?? []; |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* Returns the tags for a filesystem record. |
533
|
|
|
* |
534
|
|
|
* @param int $filesystemId |
535
|
|
|
* @param int $limit |
536
|
|
|
* @param int $offset |
537
|
|
|
* @return EntitySet |
538
|
|
|
*/ |
539
|
|
|
public function getFilesystemTagListByFilesystem( |
540
|
|
|
int $filesystemId, |
541
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
542
|
|
|
int $offset = 0 |
543
|
|
|
) : EntitySet { |
544
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
545
|
|
|
|
546
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
547
|
|
|
'getFilesystemTagListByFilesystem', |
548
|
|
|
[ |
549
|
|
|
':idFilesystem' => $filesystemId, |
550
|
|
|
':limit' => $limit, |
551
|
|
|
':offset' => $offset |
552
|
|
|
] |
553
|
|
|
); |
554
|
|
|
|
555
|
|
|
$entitySet = $this->createEntitySet(); |
556
|
|
|
|
557
|
|
|
foreach ($data as $row) { |
|
|
|
|
558
|
|
|
/** @var FilesystemTagEntity $entity */ |
559
|
|
|
$entity = $this->createEntity(FilesystemTagEntity::class, $row); |
560
|
|
|
|
561
|
|
|
if (!empty($entity)) { |
562
|
|
|
$entitySet[] = $entity; |
563
|
|
|
} |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
return $entitySet; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Returns the tags for an application. |
571
|
|
|
* |
572
|
|
|
* @param int $applicationId |
573
|
|
|
* @param int $limit |
574
|
|
|
* @param int $offset |
575
|
|
|
* @return EntitySet |
576
|
|
|
*/ |
577
|
|
|
public function getFilesystemTagListByApplication( |
578
|
|
|
int $applicationId, |
579
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
580
|
|
|
int $offset = 0 |
581
|
|
|
) : EntitySet { |
582
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
583
|
|
|
|
584
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
585
|
|
|
'getFilesystemTagListByApplication', |
586
|
|
|
[ |
587
|
|
|
':idApplication' => $applicationId, |
588
|
|
|
':limit' => $limit, |
589
|
|
|
':offset' => $offset |
590
|
|
|
] |
591
|
|
|
); |
592
|
|
|
|
593
|
|
|
$entitySet = $this->createEntitySet(); |
594
|
|
|
|
595
|
|
|
foreach ($data as $row) { |
|
|
|
|
596
|
|
|
/** @var FilesystemTagEntity $entity */ |
597
|
|
|
$entity = $this->createEntity(FilesystemTagEntity::class, $row); |
598
|
|
|
|
599
|
|
|
if (!empty($entity)) { |
600
|
|
|
$entitySet[] = $entity; |
601
|
|
|
} |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
return $entitySet; |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* Returns filesystem tag information identified by (unique) ID. |
609
|
|
|
* |
610
|
|
|
* @param int $identifier |
611
|
|
|
* @return null|FilesystemTagEntity |
612
|
|
|
*/ |
613
|
|
|
public function getFilesystemTagById(int $identifier) : ? FilesystemTagEntity |
614
|
|
|
{ |
615
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
616
|
|
|
'getFilesystemTagById', |
617
|
|
|
[ |
618
|
|
|
':idTag' => $identifier |
619
|
|
|
] |
620
|
|
|
); |
621
|
|
|
|
622
|
|
|
/** @var null|FilesystemTagEntity $entity */ |
623
|
|
|
$entity = $this->createEntity(FilesystemTagEntity::class, $data[0] ?? []); |
624
|
|
|
|
625
|
|
|
return $entity; |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Returns filesystem tag information identified by (unique) ID. |
630
|
|
|
* |
631
|
|
|
* @param int $applicationId |
632
|
|
|
* @param string $name |
633
|
|
|
* @return null|FilesystemTagEntity |
634
|
|
|
*/ |
635
|
|
|
public function getFilesystemTagByApplicationAndName( |
636
|
|
|
int $applicationId, |
637
|
|
|
string $name |
638
|
|
|
) : ? FilesystemTagEntity { |
639
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
640
|
|
|
'getFilesystemTagByApplicationAndName', |
641
|
|
|
[ |
642
|
|
|
':idApplication' => $applicationId, |
643
|
|
|
':name' => $name |
644
|
|
|
] |
645
|
|
|
); |
646
|
|
|
|
647
|
|
|
/** @var null|FilesystemTagEntity $entity */ |
648
|
|
|
$entity = $this->createEntity(FilesystemTagEntity::class, $data[0] ?? []); |
649
|
|
|
|
650
|
|
|
return $entity; |
651
|
|
|
} |
652
|
|
|
|
653
|
|
|
/** |
654
|
|
|
* Returns the categories for an application. |
655
|
|
|
* |
656
|
|
|
* @param int $applicationId |
657
|
|
|
* @param int $limit |
658
|
|
|
* @param int $offset |
659
|
|
|
* @return EntitySet |
660
|
|
|
*/ |
661
|
|
|
public function getFilesystemCategoryListByApplication( |
662
|
|
|
int $applicationId, |
663
|
|
|
int $limit = QueryInterface::MAX_ROW_LIMIT, |
664
|
|
|
int $offset = 0 |
665
|
|
|
) : EntitySet { |
666
|
|
|
$this->normalizeLimitAndOffset($limit, $offset); |
667
|
|
|
|
668
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
669
|
|
|
'getFilesystemCategoryListByApplication', |
670
|
|
|
[ |
671
|
|
|
':idApplication' => $applicationId, |
672
|
|
|
':limit' => $limit, |
673
|
|
|
':offset' => $offset |
674
|
|
|
] |
675
|
|
|
); |
676
|
|
|
|
677
|
|
|
$entitySet = $this->createEntitySet(); |
678
|
|
|
|
679
|
|
|
foreach ($data as $row) { |
|
|
|
|
680
|
|
|
/** @var FilesystemCategoryEntity $entity */ |
681
|
|
|
$entity = $this->createEntity(FilesystemCategoryEntity::class, $row); |
682
|
|
|
|
683
|
|
|
if (!empty($entity)) { |
684
|
|
|
$entitySet[] = $entity; |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
return $entitySet; |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
/** |
692
|
|
|
* Returns filesystem category information identified by (unique) ID. |
693
|
|
|
* |
694
|
|
|
* @param int $identifier |
695
|
|
|
* @return null|FilesystemCategoryEntity |
696
|
|
|
*/ |
697
|
|
|
public function getFilesystemCategoryById(int $identifier) : ? FilesystemCategoryEntity |
698
|
|
|
{ |
699
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
700
|
|
|
'getFilesystemCategoryById', |
701
|
|
|
[ |
702
|
|
|
':idCategory' => $identifier |
703
|
|
|
] |
704
|
|
|
); |
705
|
|
|
|
706
|
|
|
/** @var null|FilesystemCategoryEntity $entity */ |
707
|
|
|
$entity = $this->createEntity(FilesystemCategoryEntity::class, $data[0] ?? []); |
708
|
|
|
|
709
|
|
|
return $entity; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* Returns filesystem category information identified by application ID and category name. |
714
|
|
|
* |
715
|
|
|
* @param int $applicationId |
716
|
|
|
* @param string $categoryName |
717
|
|
|
* @return null|FilesystemCategoryEntity |
718
|
|
|
*/ |
719
|
|
|
public function getFilesystemCategoryByApplicationAndName( |
720
|
|
|
int $applicationId, |
721
|
|
|
string $categoryName |
722
|
|
|
) : ? FilesystemCategoryEntity { |
723
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
724
|
|
|
'getFilesystemCategoryByApplicationAndName', |
725
|
|
|
[ |
726
|
|
|
':idApplication' => $applicationId, |
727
|
|
|
':categoryName' => $categoryName |
728
|
|
|
] |
729
|
|
|
); |
730
|
|
|
|
731
|
|
|
/** @var null|FilesystemCategoryEntity $entity */ |
732
|
|
|
$entity = $this->createEntity(FilesystemCategoryEntity::class, $data[0] ?? []); |
733
|
|
|
|
734
|
|
|
return $entity; |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
/** |
738
|
|
|
* Returns filesystem directory information identified by (unique) ID. |
739
|
|
|
* |
740
|
|
|
* @param int $identifier |
741
|
|
|
* @return null|FilesystemDirectoryEntity |
742
|
|
|
*/ |
743
|
|
|
public function getFilesystemDirectoryById(int $identifier) : ? FilesystemDirectoryEntity |
744
|
|
|
{ |
745
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
746
|
|
|
'getFilesystemDirectoryById', |
747
|
|
|
[ |
748
|
|
|
':idDirectory' => $identifier |
749
|
|
|
] |
750
|
|
|
); |
751
|
|
|
|
752
|
|
|
/** @var null|FilesystemDirectoryEntity $entity */ |
753
|
|
|
$entity = $this->createEntity(FilesystemDirectoryEntity::class, $data[0] ?? []); |
754
|
|
|
|
755
|
|
|
return $entity; |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
/** |
759
|
|
|
* Returns filesystem directory information identified by its proxy. |
760
|
|
|
* |
761
|
|
|
* @param string $proxy |
762
|
|
|
* @return null|FilesystemDirectoryEntity |
763
|
|
|
*/ |
764
|
|
|
public function getFilesystemDirectoryByProxy(string $proxy) : ? FilesystemDirectoryEntity |
765
|
|
|
{ |
766
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
767
|
|
|
'getFilesystemDirectoryByProxy', |
768
|
|
|
[ |
769
|
|
|
':proxy' => $proxy |
770
|
|
|
] |
771
|
|
|
); |
772
|
|
|
|
773
|
|
|
/** @var null|FilesystemDirectoryEntity $entity */ |
774
|
|
|
$entity = $this->createEntity(FilesystemDirectoryEntity::class, $data[0] ?? []); |
775
|
|
|
|
776
|
|
|
return $entity; |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* Returns a combined information of the filesystem and directory according to the application and the proxy. |
781
|
|
|
* |
782
|
|
|
* @param int $applicationId |
783
|
|
|
* @param string $proxy |
784
|
|
|
* @return null|FilesystemDirectoryDataEntity |
785
|
|
|
*/ |
786
|
|
|
public function getFilesystemDirectoryDataByApplicationAndProxy( |
787
|
|
|
int $applicationId, |
788
|
|
|
string $proxy |
789
|
|
|
) : ? FilesystemDirectoryDataEntity { |
790
|
|
|
$data = $this->getQueryAdapter()->fetchData( |
791
|
|
|
'getFilesystemDirectoryDataByApplicationAndProxy', |
792
|
|
|
[ |
793
|
|
|
':idApplication' => $applicationId, |
794
|
|
|
':proxy' => $proxy |
795
|
|
|
] |
796
|
|
|
); |
797
|
|
|
|
798
|
|
|
/** @var null|FilesystemDirectoryDataEntity $entity */ |
799
|
|
|
$entity = $this->createEntity(FilesystemDirectoryDataEntity::class, $data[0] ?? []); |
800
|
|
|
|
801
|
|
|
return $entity; |
802
|
|
|
} |
803
|
|
|
} |
804
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.