TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ResourceFactory Class Reference
Inheritance diagram for ResourceFactory:
ResourceFactoryInterface SingletonInterface

Public Member Functions

 __construct (Dispatcher $signalSlotDispatcher=null)
 
 convertFlexFormDataToConfigurationArray ($flexFormData)
 
 getCollectionObject ($uid, array $recordData=[])
 
 createStorageObject (array $storageRecord, array $storageConfiguration=null)
 
 createFolderObject (ResourceStorage $storage, $identifier, $name)
 
 getFileObject ($uid, array $fileData=[])
 
 getFileObjectFromCombinedIdentifier ($identifier)
 
 getFileObjectByStorageAndIdentifier ($storageUid, &$fileIdentifier)
 
 retrieveFileOrFolderObject ($input)
 
 getFolderObjectFromCombinedIdentifier ($identifier)
 
 getStorageObjectFromCombinedIdentifier ($identifier)
 
 getObjectFromCombinedIdentifier ($identifier)
 
 getFileReferenceObject ($uid, array $fileReferenceData=[], $raw=false)
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 emitPreProcessStorageSignal ($uid, $recordData, $fileIdentifier)
 
 emitPostProcessStorageSignal (ResourceStorage $storageObject)
 
 findBestMatchingStorageByLocalPath (&$localPath)
 
 getFileReferenceData ($uid, $raw=false)
 
 getFileIndexRepository ()
 
 getProcessedFileRepository ()
 
 getIndexer (ResourceStorage $storage)
 

Protected Attributes

 $storageInstances = []
 
 $collectionInstances = []
 
 $fileInstances = []
 
 $fileReferenceInstances = []
 
 $localDriverStorageCache = null
 
 $signalSlotDispatcher
 

Additional Inherited Members

- Public Attributes inherited from ResourceFactoryInterface
const SIGNAL_PreProcessStorage = 'preProcessStorage'
 
const SIGNAL_PostProcessStorage = 'postProcessStorage'
 

Detailed Description

Factory class for FAL objects

Definition at line 31 of file ResourceFactory.php.

Constructor & Destructor Documentation

__construct ( Dispatcher  $signalSlotDispatcher = null)

Inject signal slot dispatcher

Parameters
Dispatcher$signalSlotDispatcheran instance of the signal slot dispatcher

Definition at line 80 of file ResourceFactory.php.

References ResourceFactory\$signalSlotDispatcher, and GeneralUtility\makeInstance().

Member Function Documentation

convertFlexFormDataToConfigurationArray (   $flexFormData)

Converts a flexform data string to a flat array with key value pairs

Parameters
string$flexFormData
Returns
array Array with key => value pairs of the field data in the FlexForm

Definition at line 267 of file ResourceFactory.php.

References GeneralUtility\makeInstance().

Referenced by ResourceFactory\createStorageObject().

createFolderObject ( ResourceStorage  $storage,
  $identifier,
  $name 
)

Creates a folder to directly access (a part of) a storage.

Parameters
ResourceStorage$storageThe storage the folder belongs to
string$identifierThe path to the folder. Might also be a simple unique string, depending on the storage driver.
string$nameThe name of the folder (e.g. the folder name)
Returns
Folder

Definition at line 358 of file ResourceFactory.php.

References GeneralUtility\makeInstance().

createStorageObject ( array  $storageRecord,
array  $storageConfiguration = null 
)

Creates a storage object from a storage database row.

Parameters
array$storageRecord
array$storageConfigurationStorage configuration (if given, this won't be extracted from the FlexForm value but the supplied array used instead)
Returns
ResourceStorage

Definition at line 340 of file ResourceFactory.php.

References ResourceFactory\convertFlexFormDataToConfigurationArray(), and GeneralUtility\makeInstance().

emitPostProcessStorageSignal ( ResourceStorage  $storageObject)
protected

Emits a signal after a resource storage was initialized

Parameters
ResourceStorage$storageObject

Definition at line 203 of file ResourceFactory.php.

emitPreProcessStorageSignal (   $uid,
  $recordData,
  $fileIdentifier 
)
protected

Emits a signal before a resource storage was initialized

Parameters
int$uid
array$recordData
string$fileIdentifier
Returns
mixed

Definition at line 193 of file ResourceFactory.php.

findBestMatchingStorageByLocalPath ( $localPath)
protected

Checks whether a file resides within a real storage in local file system. If no match is found, uid 0 is returned which is a fallback storage pointing to PATH_site.

The file identifier is adapted accordingly to match the new storage's base path.

Parameters
string$localPath
Returns
int

Definition at line 218 of file ResourceFactory.php.

References PathUtility\getCommonPrefix().

getCollectionObject (   $uid,
array  $recordData = [] 
)

Creates an instance of the collection from given UID. The $recordData can be supplied to increase performance.

Parameters
int$uidThe uid of the collection to instantiate.
array$recordDataThe record row from database.
Exceptions
InvalidArgumentException
Returns
Collection

Definition at line 286 of file ResourceFactory.php.

References GeneralUtility\makeInstance().

getFileIndexRepository ( )
protected

Returns an instance of the FileIndexRepository

Returns
FileIndexRepository

Definition at line 678 of file ResourceFactory.php.

References FileIndexRepository\getInstance().

Referenced by ResourceFactory\getFileObject(), and ResourceFactory\getFileObjectByStorageAndIdentifier().

getFileObject (   $uid,
array  $fileData = [] 
)

Creates an instance of the file given UID. The $fileData can be supplied to increase performance.

Parameters
int$uidThe uid of the file to instantiate.
array$fileDataThe record row from database.
Exceptions
InvalidArgumentException
ExceptionFileDoesNotExistException
Returns
File

Definition at line 374 of file ResourceFactory.php.

References ResourceFactory\getFileIndexRepository().

Referenced by ResourceFactory\getFileObjectByStorageAndIdentifier(), and ResourceFactory\retrieveFileOrFolderObject().

getFileObjectByStorageAndIdentifier (   $storageUid,
$fileIdentifier 
)

Gets an file object from storage by file identifier If the file is outside of the process folder it gets indexed and returned as file object afterwards If the file is within processing folder the file object will be directly returned

Parameters
int$storageUid
string$fileIdentifier
Returns
NULL|File|ProcessedFile

Definition at line 429 of file ResourceFactory.php.

References ResourceFactory\getFileIndexRepository(), ResourceFactory\getFileObject(), ResourceFactory\getIndexer(), and ResourceFactory\getProcessedFileRepository().

Referenced by ResourceFactory\getFileObjectFromCombinedIdentifier().

getFileObjectFromCombinedIdentifier (   $identifier)

Gets an file object from an identifier [storage]:[fileId]

Parameters
string$identifier
Returns
File
Exceptions
InvalidArgumentException

Definition at line 399 of file ResourceFactory.php.

References ResourceFactory\getFileObjectByStorageAndIdentifier(), and GeneralUtility\trimExplode().

Referenced by ResourceFactory\retrieveFileOrFolderObject().

getFileReferenceData (   $uid,
  $raw = false 
)
protected

Gets data for the given uid of the file reference record.

Parameters
int$uidThe uid of the file usage (sys_file_reference) to be fetched
bool$rawWhether to get raw results without performing overlays
Returns
NULL|array

Definition at line 650 of file ResourceFactory.php.

References $GLOBALS, BackendUtility\getRecordWSOL(), and GeneralUtility\makeInstance().

Referenced by ResourceFactory\getFileReferenceObject().

getFileReferenceObject (   $uid,
array  $fileReferenceData = [],
  $raw = false 
)

Creates an instance of a FileReference object. The $fileReferenceData can be supplied to increase performance.

Parameters
int$uidThe uid of the file usage (sys_file_reference) to instantiate.
array$fileReferenceDataThe record row from database.
bool$rawWhether to get raw results without performing overlays
Returns
FileReference
Exceptions
InvalidArgumentException
ExceptionResourceDoesNotExistException

Definition at line 604 of file ResourceFactory.php.

References ResourceFactory\getFileReferenceData().

getFolderObjectFromCombinedIdentifier (   $identifier)

Gets a folder object from an identifier [storage]:[fileId]

check naming, inserted by SteffenR while working on filelist

Parameters
string$identifier
Returns
Folder

Definition at line 514 of file ResourceFactory.php.

References GeneralUtility\isFirstPartOfStr(), PathUtility\stripPathSitePrefix(), and GeneralUtility\trimExplode().

Referenced by ResourceFactory\retrieveFileOrFolderObject().

getIndexer ( ResourceStorage  $storage)
protected

Returns an instance of the Indexer

Parameters
ResourceStorage$storage
Returns
Index

Definition at line 699 of file ResourceFactory.php.

References GeneralUtility\makeInstance().

Referenced by ResourceFactory\getFileObjectByStorageAndIdentifier().

static getInstance ( )
static

Gets a singleton instance of this class.

Returns
ResourceFactory

Definition at line 38 of file ResourceFactory.php.

References GeneralUtility\makeInstance().

Referenced by ResourceStorage\__construct(), ContentObjectRenderer\__wakeup(), ResourceStorage\addFile(), ResourceStorage\addFileMount(), OnlineMediaController\addMediaFromUrl(), SelectImageController\buildImageMarkup(), EditImageHandler\canHandleLink(), FileMetadataPermissionsAspect\checkFileWriteAccessForFileMetaData(), Import\checkImportPrerequisites(), ResourceStorage\createFile(), ShortcutToolbarItem\createShortcutAction(), FileDumpController\dumpAction(), FileStorageIndexingTask\execute(), FileStorageExtractionTask\execute(), Export\export_addFilesFromSysFilesRecords(), ClickMenu\FILE_delete(), FileExtensionFilter\filterInlineChildren(), Clipboard\getContentFromTab(), ImageManipulationElement\getFile(), ImportExportController\getFile(), ResourceStorage\getFolder(), DefaultAvatarProvider\getImage(), ResourceStorageTest\getNestedProcessingFolderTest(), File\getOriginalResource(), FileReference\getOriginalResource(), MetaInformation\getPath(), ResourceStorage\getProcessingFolder(), MetaInformation\getRecordInformation(), ReferenceIndex\getRelations_procFiles(), FileIndexRepository\getResourceFactory(), AbstractOnlineMediaHelper\getResourceFactory(), Indexer\getResourceFactory(), DataHandler\getResourceFactory(), ResourceStorage\getRootLevelFolder(), FileLinkHandler\getSelectedFolder(), ImageManipulationWizard\getWizardAction(), ContentObjectRenderer\imageLinkWrap(), FileUploadController\init(), RenameFileController\init(), ReplaceFileController\init(), EditFileController\init(), CreateFolderController\init(), ElementInformationController\initFileOrFolderRecord(), ShowImageController\initialize(), CssStyledContentController\initializeCurrentFileInContentObjectRenderer(), Import\isEquivalentObjectStorage(), ResourceStorageTest\isWithinFileMountBoundariesRespectsReadOnlyFileMounts(), CategoryBasedFileCollection\loadContents(), ClickMenu\printFileClickMenu(), Export\removeSoftrefsHavingTheSameDatabaseRelation(), CustomAttributeController\render_clickenlarge(), FileInfoHook\renderFileInfo(), FileInfoHook\renderFileMetadataInfo(), InlineRecordContainer\renderForeignRecordHeader(), ResourceStorageTest\replaceFileFailsIfLocalFileDoesNotExist(), SetupModuleController\setAvatarFileUid(), SpellCheckingController\setPersonalDictionaryPath(), Import\setRelations_db(), ExtendedFileUtility\start(), FileList\start(), RteHtmlParser\TS_links_db(), RteHtmlParser\TS_links_rte(), File\updateProperties(), FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields(), FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields(), Import\writeFileVerify(), and Import\writeSysFileStorageRecords().

getObjectFromCombinedIdentifier (   $identifier)

Gets a file or folder object.

Parameters
string$identifier
Exceptions
ExceptionResourceDoesNotExistException
Returns
FileInterface|Folder

Definition at line 557 of file ResourceFactory.php.

References GeneralUtility\trimExplode().

Referenced by ResourceFactory\retrieveFileOrFolderObject().

getProcessedFileRepository ( )
protected
getStorageObjectFromCombinedIdentifier (   $identifier)

Gets a storage object from a combined identifier

Parameters
string$identifierAn identifier of the form [storage uid]:[object identifier]
Returns
ResourceStorage

Definition at line 542 of file ResourceFactory.php.

References GeneralUtility\trimExplode().

retrieveFileOrFolderObject (   $input)

Bulk function, can be used for anything to get a file or folder

  1. It's a UID
  2. It's a combined identifier
  3. It's just a path/filename (coming from the oldstyle/backwards compatibility)

Files, previously laid on fileadmin/ or something, will be "mapped" to the storage the file is in now. Files like typo3temp/ or typo3conf/ will be moved to the first writable storage in its processing folder

$input could be

  • "2:myfolder/myfile.jpg" (combined identifier)
  • "23" (file UID)
  • "uploads/myfile.png" (backwards-compatibility, storage "0")
  • "file:23"
Parameters
string$input
Returns
File|Folder

Definition at line 466 of file ResourceFactory.php.

References PathUtility\basename(), MathUtility\canBeInterpretedAsInteger(), PathUtility\dirname(), PathUtility\getCanonicalPath(), GeneralUtility\getFileAbsFileName(), ResourceFactory\getFileObject(), ResourceFactory\getFileObjectFromCombinedIdentifier(), ResourceFactory\getFolderObjectFromCombinedIdentifier(), ResourceFactory\getObjectFromCombinedIdentifier(), PathUtility\getRelativePath(), and GeneralUtility\isFirstPartOfStr().

Member Data Documentation

$collectionInstances = []
protected

Definition at line 51 of file ResourceFactory.php.

$fileInstances = []
protected

Definition at line 56 of file ResourceFactory.php.

$fileReferenceInstances = []
protected

Definition at line 61 of file ResourceFactory.php.

$localDriverStorageCache = null
protected

Definition at line 68 of file ResourceFactory.php.

$signalSlotDispatcher
protected

Definition at line 73 of file ResourceFactory.php.

Referenced by ResourceFactory\__construct().

$storageInstances = []
protected

Definition at line 46 of file ResourceFactory.php.