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