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