ResourceFactory implements SingletonInterface
Factory class for FAL objects
Table of Contents
Interfaces
- SingletonInterface
- "empty" interface for singletons (marker interface pattern)
Properties
- $collectionInstances : array<int, CollectionInterface<string|int, File>>
- $fileInstances : array<string|int, File>
- $fileReferenceInstances : array<string|int, FileReference>
- $storageRepository : StorageRepository
Methods
- __construct() : mixed
- convertFlexFormDataToConfigurationArray() : array<string|int, mixed>
- Converts a flexform data string to a flat array with key value pairs.
- createCollectionObject() : CollectionInterface<string|int, File>
- Creates a collection object.
- createFileObject() : File
- Creates a file object from an array of file data. Requires a database row to be fetched.
- createFileReferenceObject() : FileReference
- Creates a file usage object from an array of fileReference data from sys_file_reference table.
- createFolderObject() : Folder
- Creates a folder to directly access (a part of) a storage.
- createStorageObject() : ResourceStorage
- Creates a storage object from a storage database row.
- getCollectionObject() : AbstractFileCollection
- Creates an instance of the collection from given UID. The $recordData can be supplied to increase performance.
- getDefaultStorage() : ResourceStorage|null
- Returns the Default Storage
- getFileObject() : File
- Creates an instance of the file given UID. The $fileData can be supplied to increase performance.
- getFileObjectByStorageAndIdentifier() : File|ProcessedFile|null
- Gets a 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
- getFileObjectFromCombinedIdentifier() : File|ProcessedFile|null
- Gets a file object from an identifier [storage]:[fileId]
- getFileReferenceObject() : FileReference
- Creates an instance of a FileReference object. The $fileReferenceData can be supplied to increase performance.
- getFolderObjectFromCombinedIdentifier() : Folder
- Gets a folder object from an identifier [storage]:[fileId]
- getObjectFromCombinedIdentifier() : FileInterface|Folder
- Gets a file or folder object.
- getStorageObject() : ResourceStorage
- Creates an instance of the storage from given UID. The $recordData can be supplied to increase performance.
- getStorageObjectFromCombinedIdentifier() : ResourceStorage
- Gets a storage object from a combined identifier
- retrieveFileOrFolderObject() : File|Folder|null
- Bulk function, can be used for anything to get a file or folder
- getFileIndexRepository() : FileIndexRepository
- Returns an instance of the FileIndexRepository
- getFileReferenceData() : array<string|int, mixed>|null
- Gets data for the given uid of the file reference record.
Properties
$collectionInstances
protected
array<int, CollectionInterface<string|int, File>>
$collectionInstances
= []
$fileInstances
protected
array<string|int, File>
$fileInstances
= []
$fileReferenceInstances
protected
array<string|int, FileReference>
$fileReferenceInstances
= []
$storageRepository
protected
StorageRepository
$storageRepository
Methods
__construct()
public
__construct(StorageRepository $storageRepository) : mixed
Parameters
- $storageRepository : StorageRepository
convertFlexFormDataToConfigurationArray()
Converts a flexform data string to a flat array with key value pairs.
public
convertFlexFormDataToConfigurationArray(string $flexFormData) : array<string|int, mixed>
It is recommended to not use this functionality directly, and instead implement this code yourself, as this code has nothing to do with a Public API for Resources.
Parameters
- $flexFormData : string
Return values
array<string|int, mixed> —Array with key => value pairs of the field data in the FlexForm
createCollectionObject()
Creates a collection object.
public
createCollectionObject(array<string|int, mixed> $collectionData) : CollectionInterface<string|int, File>
Parameters
- $collectionData : array<string|int, mixed>
-
The database row of the sys_file_collection record.
Return values
CollectionInterface<string|int, File>createFileObject()
Creates a file object from an array of file data. Requires a database row to be fetched.
public
createFileObject(array<string|int, mixed> $fileData[, ResourceStorage|null $storage = null ]) : File
Parameters
- $fileData : array<string|int, mixed>
- $storage : ResourceStorage|null = null
Return values
FilecreateFileReferenceObject()
Creates a file usage object from an array of fileReference data from sys_file_reference table.
public
createFileReferenceObject(array<string|int, mixed> $fileReferenceData) : FileReference
Requires a database row to be already fetched and present.
Parameters
- $fileReferenceData : array<string|int, mixed>
Return values
FileReferencecreateFolderObject()
Creates a folder to directly access (a part of) a storage.
public
createFolderObject(ResourceStorage $storage, string $identifier, string $name) : Folder
Parameters
- $storage : ResourceStorage
-
The storage the folder belongs to
- $identifier : string
-
The path to the folder. Might also be a simple unique string, depending on the storage driver.
- $name : string
-
The name of the folder (e.g. the folder name)
it is recommended to access the ResourceStorage object directly and access ->getFolder($identifier) this method is kept for backwards compatibility
Return values
FoldercreateStorageObject()
Creates a storage object from a storage database row.
public
createStorageObject(array<string|int, mixed> $storageRecord[, array<string|int, mixed>|null $storageConfiguration = null ]) : ResourceStorage
Parameters
- $storageRecord : array<string|int, mixed>
- $storageConfiguration : array<string|int, mixed>|null = null
-
Storage configuration (if given, this won't be extracted from the FlexForm value but the supplied array used instead)
It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer
Return values
ResourceStoragegetCollectionObject()
Creates an instance of the collection from given UID. The $recordData can be supplied to increase performance.
public
getCollectionObject(int $uid[, array<string|int, mixed> $recordData = [] ]) : AbstractFileCollection
Parameters
- $uid : int
-
The uid of the collection to instantiate.
- $recordData : array<string|int, mixed> = []
-
The record row from database.
Tags
Return values
AbstractFileCollectiongetDefaultStorage()
Returns the Default Storage
public
getDefaultStorage() : ResourceStorage|null
The Default Storage is considered to be the replacement for the fileadmin/ construct. It is automatically created with the setting fileadminDir from install tool. getDefaultStorage->getDefaultFolder() will get you fileadmin/user_upload/ in a standard TYPO3 installation.
It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer
Return values
ResourceStorage|nullgetFileObject()
Creates an instance of the file given UID. The $fileData can be supplied to increase performance.
public
getFileObject(int $uid[, array<string|int, mixed> $fileData = [] ]) : File
Parameters
- $uid : int
-
The uid of the file to instantiate.
- $fileData : array<string|int, mixed> = []
-
The record row from database.
Tags
Return values
FilegetFileObjectByStorageAndIdentifier()
Gets a 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
public
getFileObjectByStorageAndIdentifier(ResourceStorage|int $storage, string &$fileIdentifier) : File|ProcessedFile|null
Parameters
- $storage : ResourceStorage|int
- $fileIdentifier : string
It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer
Return values
File|ProcessedFile|nullgetFileObjectFromCombinedIdentifier()
Gets a file object from an identifier [storage]:[fileId]
public
getFileObjectFromCombinedIdentifier(string $identifier) : File|ProcessedFile|null
Parameters
- $identifier : string
Tags
Return values
File|ProcessedFile|nullgetFileReferenceObject()
Creates an instance of a FileReference object. The $fileReferenceData can be supplied to increase performance.
public
getFileReferenceObject(int $uid[, array<string|int, mixed> $fileReferenceData = [] ][, bool $raw = false ]) : FileReference
Parameters
- $uid : int
-
The uid of the file usage (sys_file_reference) to instantiate.
- $fileReferenceData : array<string|int, mixed> = []
-
The record row from database.
- $raw : bool = false
-
Whether to get raw results without performing overlays
Tags
Return values
FileReferencegetFolderObjectFromCombinedIdentifier()
Gets a folder object from an identifier [storage]:[fileId]
public
getFolderObjectFromCombinedIdentifier(string $identifier) : Folder
Parameters
- $identifier : string
Tags
Return values
FoldergetObjectFromCombinedIdentifier()
Gets a file or folder object.
public
getObjectFromCombinedIdentifier(string $identifier) : FileInterface|Folder
Parameters
- $identifier : string
Tags
Return values
FileInterface|FoldergetStorageObject()
Creates an instance of the storage from given UID. The $recordData can be supplied to increase performance.
public
getStorageObject(int|null $uid[, array<string|int, mixed> $recordData = [] ][, string &$fileIdentifier = null ]) : ResourceStorage
Parameters
- $uid : int|null
-
The uid of the storage to instantiate.
- $recordData : array<string|int, mixed> = []
-
The record row from database.
- $fileIdentifier : string = null
-
Identifier for a file. Used for auto-detection of a storage, but only if $uid === 0 (Local default storage) is used
It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer
Tags
Return values
ResourceStoragegetStorageObjectFromCombinedIdentifier()
Gets a storage object from a combined identifier
public
getStorageObjectFromCombinedIdentifier(string $identifier) : ResourceStorage
Parameters
- $identifier : string
-
An identifier of the form [storage uid]:[object identifier]
It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer
Return values
ResourceStorageretrieveFileOrFolderObject()
Bulk function, can be used for anything to get a file or folder
public
retrieveFileOrFolderObject(string $input) : File|Folder|null
- It's a UID
- It's a combined identifier
- 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
- $input : string
Return values
File|Folder|nullgetFileIndexRepository()
Returns an instance of the FileIndexRepository
protected
getFileIndexRepository() : FileIndexRepository
Return values
FileIndexRepositorygetFileReferenceData()
Gets data for the given uid of the file reference record.
protected
getFileReferenceData(int $uid[, bool $raw = false ]) : array<string|int, mixed>|null
Parameters
- $uid : int
-
The uid of the file usage (sys_file_reference) to be fetched
- $raw : bool = false
-
Whether to get raw results without performing overlays