[TASK] Use FlexFormService to convert FAL driver configuration
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / ResourceFactory.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Core\Utility\MathUtility;
20 use TYPO3\CMS\Core\Utility\PathUtility;
21 use TYPO3\CMS\Extbase\Service\FlexFormService;
22
23 // @todo implement constructor-level caching
24 /**
25 * Factory class for FAL objects
26 */
27 class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\SingletonInterface
28 {
29 /**
30 * Gets a singleton instance of this class.
31 *
32 * @return ResourceFactory
33 */
34 public static function getInstance()
35 {
36 return GeneralUtility::makeInstance(__CLASS__);
37 }
38
39 /**
40 * @var ResourceStorage[]
41 */
42 protected $storageInstances = array();
43
44 /**
45 * @var Collection\AbstractFileCollection[]
46 */
47 protected $collectionInstances = array();
48
49 /**
50 * @var File[]
51 */
52 protected $fileInstances = array();
53
54 /**
55 * @var FileReference[]
56 */
57 protected $fileReferenceInstances = array();
58
59 /**
60 * A list of the base paths of "local" driver storages. Used to make the detection of base paths easier.
61 *
62 * @var array
63 */
64 protected $localDriverStorageCache = null;
65
66 /**
67 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
68 */
69 protected $signalSlotDispatcher;
70
71 /**
72 * Inject signal slot dispatcher
73 */
74 public function __construct(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher = null)
75 {
76 $this->signalSlotDispatcher = $signalSlotDispatcher ?: GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
77 }
78
79 /**
80 * Creates a driver object for a specified storage object.
81 *
82 * @param string $driverIdentificationString The driver class (or identifier) to use.
83 * @param array $driverConfiguration The configuration of the storage
84 * @return Driver\DriverInterface
85 * @throws \InvalidArgumentException
86 */
87 public function getDriverObject($driverIdentificationString, array $driverConfiguration)
88 {
89 /** @var $driverRegistry Driver\DriverRegistry */
90 $driverRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class);
91 $driverClass = $driverRegistry->getDriverClass($driverIdentificationString);
92 $driverObject = GeneralUtility::makeInstance($driverClass, $driverConfiguration);
93 return $driverObject;
94 }
95
96
97 /**
98 * Returns the Default Storage
99 *
100 * The Default Storage is considered to be the replacement for the fileadmin/ construct.
101 * It is automatically created with the setting fileadminDir from install tool.
102 * getDefaultStorage->getDefaultFolder() will get you fileadmin/user_upload/ in a standard
103 * TYPO3 installation.
104 *
105 * @return null|ResourceStorage
106 */
107 public function getDefaultStorage()
108 {
109 /** @var $storageRepository StorageRepository */
110 $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
111
112 $allStorages = $storageRepository->findAll();
113 foreach ($allStorages as $storage) {
114 if ($storage->isDefault()) {
115 return $storage;
116 }
117 }
118 return null;
119 }
120 /**
121 * Creates an instance of the storage from given UID. The $recordData can
122 * be supplied to increase performance.
123 *
124 * @param int $uid The uid of the storage to instantiate.
125 * @param array $recordData The record row from database.
126 * @param string $fileIdentifier Identifier for a file. Used for auto-detection of a storage, but only if $uid === 0 (Local default storage) is used
127 *
128 * @throws \InvalidArgumentException
129 * @return ResourceStorage
130 */
131 public function getStorageObject($uid, array $recordData = array(), &$fileIdentifier = null)
132 {
133 if (!is_numeric($uid)) {
134 throw new \InvalidArgumentException('The UID of storage has to be numeric. UID given: "' . $uid . '"', 1314085991);
135 }
136 $uid = (int)$uid;
137 if ($uid === 0 && $fileIdentifier !== null) {
138 $uid = $this->findBestMatchingStorageByLocalPath($fileIdentifier);
139 }
140 if (!$this->storageInstances[$uid]) {
141 $storageConfiguration = null;
142 $storageObject = null;
143 // If the built-in storage with UID=0 is requested:
144 if ($uid === 0) {
145 $recordData = array(
146 'uid' => 0,
147 'pid' => 0,
148 'name' => 'Fallback Storage',
149 'description' => 'Internal storage, mounting the main TYPO3_site directory.',
150 'driver' => 'Local',
151 'processingfolder' => 'typo3temp/_processed_/',
152 // legacy code
153 'configuration' => '',
154 'is_online' => true,
155 'is_browsable' => true,
156 'is_public' => true,
157 'is_writable' => true,
158 'is_default' => false,
159 );
160 $storageConfiguration = array(
161 'basePath' => '/',
162 'pathType' => 'relative'
163 );
164 } elseif (count($recordData) === 0 || (int)$recordData['uid'] !== $uid) {
165 /** @var $storageRepository StorageRepository */
166 $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
167 /** @var $storage ResourceStorage */
168 $storageObject = $storageRepository->findByUid($uid);
169 }
170 if (!$storageObject instanceof ResourceStorage) {
171 $storageObject = $this->createStorageObject($recordData, $storageConfiguration);
172 }
173 $this->emitPostProcessStorageSignal($storageObject);
174 $this->storageInstances[$uid] = $storageObject;
175 }
176 return $this->storageInstances[$uid];
177 }
178
179 /**
180 * Emits a signal after a resource storage was initialized
181 *
182 * @param ResourceStorage $storageObject
183 */
184 protected function emitPostProcessStorageSignal(ResourceStorage $storageObject)
185 {
186 $this->signalSlotDispatcher->dispatch(\TYPO3\CMS\Core\Resource\ResourceFactory::class, self::SIGNAL_PostProcessStorage, array($this, $storageObject));
187 }
188
189 /**
190 * Checks whether a file resides within a real storage in local file system.
191 * If no match is found, uid 0 is returned which is a fallback storage pointing to PATH_site.
192 *
193 * The file identifier is adapted accordingly to match the new storage's base path.
194 *
195 * @param string $localPath
196 *
197 * @return int
198 */
199 protected function findBestMatchingStorageByLocalPath(&$localPath)
200 {
201 if ($this->localDriverStorageCache === null) {
202 $this->initializeLocalStorageCache();
203 }
204
205 $bestMatchStorageUid = 0;
206 $bestMatchLength = 0;
207 foreach ($this->localDriverStorageCache as $storageUid => $basePath) {
208 $matchLength = strlen(PathUtility::getCommonPrefix(array($basePath, $localPath)));
209 $basePathLength = strlen($basePath);
210
211 if ($matchLength >= $basePathLength && $matchLength > $bestMatchLength) {
212 $bestMatchStorageUid = (int)$storageUid;
213 $bestMatchLength = $matchLength;
214 }
215 }
216 if ($bestMatchStorageUid !== 0) {
217 $localPath = substr($localPath, $bestMatchLength);
218 }
219 return $bestMatchStorageUid;
220 }
221
222 /**
223 * Creates an array mapping all uids to the basePath of storages using the "local" driver.
224 *
225 * @return void
226 */
227 protected function initializeLocalStorageCache()
228 {
229 /** @var $storageRepository StorageRepository */
230 $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
231 /** @var $storageObjects ResourceStorage[] */
232 $storageObjects = $storageRepository->findByStorageType('Local');
233
234 $storageCache = array();
235 foreach ($storageObjects as $localStorage) {
236 $configuration = $localStorage->getConfiguration();
237 $storageCache[$localStorage->getUid()] = $configuration['basePath'];
238 }
239 $this->localDriverStorageCache = $storageCache;
240 }
241
242 /**
243 * Converts a flexform data string to a flat array with key value pairs
244 *
245 * @param string $flexFormData
246 * @return array Array with key => value pairs of the field data in the FlexForm
247 */
248 public function convertFlexFormDataToConfigurationArray($flexFormData)
249 {
250 $configuration = array();
251 if ($flexFormData) {
252 $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
253 $configuration = $flexFormService->convertFlexFormContentToArray($flexFormData);
254 }
255 return $configuration;
256 }
257
258 /**
259 * Creates an instance of the collection from given UID. The $recordData can be supplied to increase performance.
260 *
261 * @param int $uid The uid of the collection to instantiate.
262 * @param array $recordData The record row from database.
263 *
264 * @throws \InvalidArgumentException
265 * @return Collection\AbstractFileCollection
266 */
267 public function getCollectionObject($uid, array $recordData = array())
268 {
269 if (!is_numeric($uid)) {
270 throw new \InvalidArgumentException('The UID of collection has to be numeric. UID given: "' . $uid . '"', 1314085999);
271 }
272 if (!$this->collectionInstances[$uid]) {
273 // Get mount data if not already supplied as argument to this function
274 if (empty($recordData) || $recordData['uid'] !== $uid) {
275 /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
276 $recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_collection', 'uid=' . (int)$uid . ' AND deleted=0');
277 if (!is_array($recordData)) {
278 throw new \InvalidArgumentException('No collection found for given UID: "' . $uid . '"', 1314085992);
279 }
280 }
281 $collectionObject = $this->createCollectionObject($recordData);
282 $this->collectionInstances[$uid] = $collectionObject;
283 }
284 return $this->collectionInstances[$uid];
285 }
286
287 /**
288 * Creates a collection object.
289 *
290 * @param array $collectionData The database row of the sys_file_collection record.
291 * @return Collection\AbstractFileCollection
292 */
293 public function createCollectionObject(array $collectionData)
294 {
295 /** @var $registry Collection\FileCollectionRegistry */
296 $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Collection\FileCollectionRegistry::class);
297 $class = $registry->getFileCollectionClass($collectionData['type']);
298
299 return $class::create($collectionData);
300 }
301
302 /**
303 * Creates a storage object from a storage database row.
304 *
305 * @param array $storageRecord
306 * @param array $storageConfiguration Storage configuration (if given, this won't be extracted from the FlexForm value but the supplied array used instead)
307 * @return ResourceStorage
308 */
309 public function createStorageObject(array $storageRecord, array $storageConfiguration = null)
310 {
311 $className = \TYPO3\CMS\Core\Resource\ResourceStorage::class;
312 if (!$storageConfiguration) {
313 $storageConfiguration = $this->convertFlexFormDataToConfigurationArray($storageRecord['configuration']);
314 }
315 $driverType = $storageRecord['driver'];
316 $driverObject = $this->getDriverObject($driverType, $storageConfiguration);
317 return GeneralUtility::makeInstance($className, $driverObject, $storageRecord);
318 }
319
320 /**
321 * Creates a folder to directly access (a part of) a storage.
322 *
323 * @param ResourceStorage $storage The storage the folder belongs to
324 * @param string $identifier The path to the folder. Might also be a simple unique string, depending on the storage driver.
325 * @param string $name The name of the folder (e.g. the folder name)
326 * @return Folder
327 */
328 public function createFolderObject(ResourceStorage $storage, $identifier, $name)
329 {
330 return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Folder::class, $storage, $identifier, $name);
331 }
332
333 /**
334 * Creates an instance of the file given UID. The $fileData can be supplied
335 * to increase performance.
336 *
337 * @param int $uid The uid of the file to instantiate.
338 * @param array $fileData The record row from database.
339 *
340 * @throws \InvalidArgumentException
341 * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
342 * @return File
343 */
344 public function getFileObject($uid, array $fileData = array())
345 {
346 if (!is_numeric($uid)) {
347 throw new \InvalidArgumentException('The UID of file has to be numeric. UID given: "' . $uid . '"', 1300096564);
348 }
349 if (!$this->fileInstances[$uid]) {
350 // Fetches data in case $fileData is empty
351 if (empty($fileData)) {
352 $fileData = $this->getFileIndexRepository()->findOneByUid($uid);
353 if ($fileData === false) {
354 throw new \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException('No file found for given UID:' . $uid, 1317178604);
355 }
356 }
357 $this->fileInstances[$uid] = $this->createFileObject($fileData);
358 }
359 return $this->fileInstances[$uid];
360 }
361
362 /**
363 * Gets an file object from an identifier [storage]:[fileId]
364 *
365 * @param string $identifier
366 * @return File
367 * @throws \InvalidArgumentException
368 */
369 public function getFileObjectFromCombinedIdentifier($identifier)
370 {
371 if (!isset($identifier) || !is_string($identifier) || $identifier === '') {
372 throw new \InvalidArgumentException('Invalid file identifier given. It must be of type string and not empty. "' . gettype($identifier) . '" given.', 1401732564);
373 }
374 $parts = GeneralUtility::trimExplode(':', $identifier);
375 if (count($parts) === 2) {
376 $storageUid = $parts[0];
377 $fileIdentifier = $parts[1];
378 } else {
379 // We only got a path: Go into backwards compatibility mode and
380 // use virtual Storage (uid=0)
381 $storageUid = 0;
382 $fileIdentifier = $parts[0];
383 }
384
385 // please note that getStorageObject() might modify $fileIdentifier when
386 // auto-detecting the best-matching storage to use
387 return $this->getFileObjectByStorageAndIdentifier($storageUid, $fileIdentifier);
388 }
389
390 /**
391 * Gets an file object from storage by file identifier
392 * If the file is outside of the process folder it gets indexed and returned as file object afterwards
393 * If the file is within processing folder the file object will be directly returned
394 *
395 * @param int $storageUid
396 * @param string $fileIdentifier
397 * @return NULL|File|ProcessedFile
398 */
399 public function getFileObjectByStorageAndIdentifier($storageUid, &$fileIdentifier)
400 {
401 $storage = $this->getStorageObject($storageUid, array(), $fileIdentifier);
402 if (!$storage->isWithinProcessingFolder($fileIdentifier)) {
403 $fileData = $this->getFileIndexRepository()->findOneByStorageUidAndIdentifier($storage->getUid(), $fileIdentifier);
404 if ($fileData === false) {
405 $fileObject = $this->getIndexer($storage)->createIndexEntry($fileIdentifier);
406 } else {
407 $fileObject = $this->getFileObject($fileData['uid'], $fileData);
408 }
409 } else {
410 $fileObject = $this->getProcessedFileRepository()->findByStorageAndIdentifier($storage, $fileIdentifier);
411 }
412
413 return $fileObject;
414 }
415
416 /**
417 * Bulk function, can be used for anything to get a file or folder
418 *
419 * 1. It's a UID
420 * 2. It's a combined identifier
421 * 3. It's just a path/filename (coming from the oldstyle/backwards compatibility)
422 *
423 * Files, previously laid on fileadmin/ or something, will be "mapped" to the storage the file is
424 * in now. Files like typo3temp/ or typo3conf/ will be moved to the first writable storage
425 * in its processing folder
426 *
427 * $input could be
428 * - "2:myfolder/myfile.jpg" (combined identifier)
429 * - "23" (file UID)
430 * - "uploads/myfile.png" (backwards-compatibility, storage "0")
431 * - "file:23"
432 *
433 * @param string $input
434 * @return File|Folder
435 */
436 public function retrieveFileOrFolderObject($input)
437 {
438 // Remove PATH_site because absolute paths under Windows systems contain ':'
439 // This is done in all considered sub functions anyway
440 $input = str_replace(PATH_site, '', $input);
441
442 if (GeneralUtility::isFirstPartOfStr($input, 'file:')) {
443 $input = substr($input, 5);
444 return $this->retrieveFileOrFolderObject($input);
445 } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($input)) {
446 return $this->getFileObject($input);
447 } elseif (strpos($input, ':') > 0) {
448 list($prefix, $folderIdentifier) = explode(':', $input);
449 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($prefix)) {
450 // path or folder in a valid storageUID
451 return $this->getObjectFromCombinedIdentifier($input);
452 } elseif ($prefix == 'EXT') {
453 $input = GeneralUtility::getFileAbsFileName($input);
454 if (empty($input)) {
455 return null;
456 }
457
458 $input = PathUtility::getRelativePath(PATH_site, PathUtility::dirname($input)) . PathUtility::basename($input);
459 return $this->getFileObjectFromCombinedIdentifier($input);
460 } else {
461 return null;
462 }
463 } else {
464 // this is a backwards-compatible way to access "0-storage" files or folders
465 // eliminate double slashes, /./ and /../
466 $input = \TYPO3\CMS\Core\Utility\PathUtility::getCanonicalPath(ltrim($input, '/'));
467 if (@is_file(PATH_site . $input)) {
468 // only the local file
469 return $this->getFileObjectFromCombinedIdentifier($input);
470 } else {
471 // only the local path
472 return $this->getFolderObjectFromCombinedIdentifier($input);
473 }
474 }
475 }
476
477 /**
478 * Gets a folder object from an identifier [storage]:[fileId]
479 *
480 * @TODO check naming, inserted by SteffenR while working on filelist
481 * @param string $identifier
482 * @return Folder
483 */
484 public function getFolderObjectFromCombinedIdentifier($identifier)
485 {
486 $parts = GeneralUtility::trimExplode(':', $identifier);
487 if (count($parts) === 2) {
488 $storageUid = $parts[0];
489 $folderIdentifier = $parts[1];
490 } else {
491 // We only got a path: Go into backwards compatibility mode and
492 // use virtual Storage (uid=0)
493 $storageUid = 0;
494
495 // please note that getStorageObject() might modify $folderIdentifier when
496 // auto-detecting the best-matching storage to use
497 $folderIdentifier = $parts[0];
498 // make sure to not use an absolute path, and remove PATH_site if it is prepended
499 if (GeneralUtility::isFirstPartOfStr($folderIdentifier, PATH_site)) {
500 $folderIdentifier = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($parts[0]);
501 }
502 }
503 return $this->getStorageObject($storageUid, array(), $folderIdentifier)->getFolder($folderIdentifier);
504 }
505
506 /**
507 * Gets a storage object from a combined identifier
508 *
509 * @param string $identifier An identifier of the form [storage uid]:[object identifier]
510 * @return ResourceStorage
511 */
512 public function getStorageObjectFromCombinedIdentifier($identifier)
513 {
514 $parts = GeneralUtility::trimExplode(':', $identifier);
515 $storageUid = count($parts) === 2 ? $parts[0] : null;
516 return $this->getStorageObject($storageUid);
517 }
518
519 /**
520 * Gets a file or folder object.
521 *
522 * @param string $identifier
523 *
524 * @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
525 * @return FileInterface|Folder
526 */
527 public function getObjectFromCombinedIdentifier($identifier)
528 {
529 list($storageId, $objectIdentifier) = GeneralUtility::trimExplode(':', $identifier);
530 $storage = $this->getStorageObject($storageId);
531 if ($storage->hasFile($objectIdentifier)) {
532 return $storage->getFile($objectIdentifier);
533 } elseif ($storage->hasFolder($objectIdentifier)) {
534 return $storage->getFolder($objectIdentifier);
535 } else {
536 throw new \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException('Object with identifier "' . $identifier . '" does not exist in storage', 1329647780);
537 }
538 }
539
540 /**
541 * Creates a file object from an array of file data. Requires a database
542 * row to be fetched.
543 *
544 * @param array $fileData
545 * @param ResourceStorage $storage
546 * @return File
547 */
548 public function createFileObject(array $fileData, ResourceStorage $storage = null)
549 {
550 /** @var File $fileObject */
551 if (array_key_exists('storage', $fileData) && MathUtility::canBeInterpretedAsInteger($fileData['storage'])) {
552 $storageObject = $this->getStorageObject((int)$fileData['storage']);
553 } elseif ($storage !== null) {
554 $storageObject = $storage;
555 $fileData['storage'] = $storage->getUid();
556 } else {
557 throw new \RuntimeException('A file needs to reside in a Storage', 1381570997);
558 }
559 $fileObject = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\File::class, $fileData, $storageObject);
560 return $fileObject;
561 }
562
563 /**
564 * Creates an instance of a FileReference object. The $fileReferenceData can
565 * be supplied to increase performance.
566 *
567 * @param int $uid The uid of the file usage (sys_file_reference) to instantiate.
568 * @param array $fileReferenceData The record row from database.
569 * @param bool $raw Whether to get raw results without performing overlays
570 * @return FileReference
571 * @throws \InvalidArgumentException
572 * @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
573 */
574 public function getFileReferenceObject($uid, array $fileReferenceData = array(), $raw = false)
575 {
576 if (!is_numeric($uid)) {
577 throw new \InvalidArgumentException(
578 'The reference UID for the file (sys_file_reference) has to be numeric. UID given: "' . $uid . '"',
579 1300086584
580 );
581 }
582 if (!$this->fileReferenceInstances[$uid]) {
583 // Fetches data in case $fileData is empty
584 if (empty($fileReferenceData)) {
585 $fileReferenceData = $this->getFileReferenceData($uid, $raw);
586 if (!is_array($fileReferenceData)) {
587 throw new \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException(
588 'No file reference (sys_file_reference) was found for given UID: "' . $uid . '"',
589 1317178794
590 );
591 }
592 }
593 $this->fileReferenceInstances[$uid] = $this->createFileReferenceObject($fileReferenceData);
594 }
595 return $this->fileReferenceInstances[$uid];
596 }
597
598 /**
599 * Creates a file usage object from an array of fileReference data
600 * from sys_file_reference table.
601 * Requires a database row to be already fetched and present.
602 *
603 * @param array $fileReferenceData
604 * @return FileReference
605 */
606 public function createFileReferenceObject(array $fileReferenceData)
607 {
608 /** @var FileReference $fileReferenceObject */
609 $fileReferenceObject = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileReference::class, $fileReferenceData);
610 return $fileReferenceObject;
611 }
612
613 /**
614 * Gets data for the given uid of the file reference record.
615 *
616 * @param int $uid The uid of the file usage (sys_file_reference) to be fetched
617 * @param bool $raw Whether to get raw results without performing overlays
618 * @return NULL|array
619 */
620 protected function getFileReferenceData($uid, $raw = false)
621 {
622 if (!$raw && TYPO3_MODE === 'BE') {
623 $fileReferenceData = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('sys_file_reference', $uid);
624 } elseif (!$raw && is_object($GLOBALS['TSFE'])) {
625 $fileReferenceData = $GLOBALS['TSFE']->sys_page->checkRecord('sys_file_reference', $uid);
626 } else {
627 /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
628 $fileReferenceData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', 'uid=' . (int)$uid . ' AND deleted=0');
629 }
630 return $fileReferenceData;
631 }
632
633 /**
634 * Returns an instance of the FileIndexRepository
635 *
636 * @return FileIndexRepository
637 */
638 protected function getFileIndexRepository()
639 {
640 return FileIndexRepository::getInstance();
641 }
642
643 /**
644 * Returns an instance of the ProcessedFileRepository
645 *
646 * @return ProcessedFileRepository
647 */
648 protected function getProcessedFileRepository()
649 {
650 return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ProcessedFileRepository::class);
651 }
652
653 /**
654 * Returns an instance of the Indexer
655 *
656 * @return \TYPO3\CMS\Core\Resource\Index\Indexer
657 */
658 protected function getIndexer(ResourceStorage $storage)
659 {
660 return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Index\Indexer::class, $storage);
661 }
662 }