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