‪TYPO3CMS  11.5
TYPO3\CMS\Core\Resource\ResourceFactory Class Reference
Inheritance diagram for TYPO3\CMS\Core\Resource\ResourceFactory:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (StorageRepository $storageRepository)
 
ResourceStorage null getDefaultStorage ()
 
ResourceStorage getStorageObject ($uid, array $recordData=[], &$fileIdentifier=null)
 
array convertFlexFormDataToConfigurationArray ($flexFormData)
 
Collection AbstractFileCollection getCollectionObject ($uid, array $recordData=[])
 
CollectionInterface< FilecreateCollectionObject (array $collectionData)
 
ResourceStorage createStorageObject (array $storageRecord, ?array $storageConfiguration=null)
 
Folder createFolderObject (ResourceStorage $storage, $identifier, $name)
 
File getFileObject ($uid, array $fileData=[])
 
File ProcessedFile null getFileObjectFromCombinedIdentifier ($identifier)
 
File ProcessedFile null getFileObjectByStorageAndIdentifier ($storage, &$fileIdentifier)
 
File Folder null retrieveFileOrFolderObject ($input)
 
Folder getFolderObjectFromCombinedIdentifier ($identifier)
 
ResourceStorage getStorageObjectFromCombinedIdentifier ($identifier)
 
FileInterface Folder getObjectFromCombinedIdentifier ($identifier)
 
File createFileObject (array $fileData, ?ResourceStorage $storage=null)
 
FileReference getFileReferenceObject ($uid, array $fileReferenceData=[], $raw=false)
 
FileReference createFileReferenceObject (array $fileReferenceData)
 

Protected Member Functions

array null getFileReferenceData ($uid, $raw=false)
 
FileIndexRepository getFileIndexRepository ()
 

Protected Attributes

array< int, CollectionInterface< File > > $collectionInstances = array( )
 
File[] $fileInstances = array( )
 
FileReference[] $fileReferenceInstances = array( )
 
StorageRepository $storageRepository
 

Detailed Description

Factory class for FAL objects

Definition at line 40 of file ResourceFactory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\ResourceFactory::__construct ( StorageRepository  $storageRepository)

Member Function Documentation

◆ convertFlexFormDataToConfigurationArray()

array TYPO3\CMS\Core\Resource\ResourceFactory::convertFlexFormDataToConfigurationArray (   $flexFormData)

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

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
string$flexFormData
Returns
‪array Array with key => value pairs of the field data in the FlexForm

Definition at line 106 of file ResourceFactory.php.

◆ createCollectionObject()

CollectionInterface<File> TYPO3\CMS\Core\Resource\ResourceFactory::createCollectionObject ( array  $collectionData)

Creates a collection object.

Parameters
array$collectionData‪The database row of the sys_file_collection record.
Returns
‪CollectionInterface<File>

Definition at line 161 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\FileCollectionRepository\createDomainObject(), and TYPO3\CMS\Core\Resource\ResourceFactory\getCollectionObject().

◆ createFileObject()

File TYPO3\CMS\Core\Resource\ResourceFactory::createFileObject ( array  $fileData,
?ResourceStorage  $storage = null 
)

Creates a file object from an array of file data. Requires a database row to be fetched.

Parameters
array$fileData
ResourceStorage | null$storage
Returns
File

Definition at line 420 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), and TYPO3\CMS\Core\Resource\AbstractFile\getUid().

Referenced by TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject().

◆ createFileReferenceObject()

FileReference TYPO3\CMS\Core\Resource\ResourceFactory::createFileReferenceObject ( array  $fileReferenceData)

Creates a file usage object from an array of fileReference data from sys_file_reference table. Requires a database row to be already fetched and present.

Parameters
array$fileReferenceData
Returns
FileReference

Definition at line 477 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceFactory\getFileReferenceObject().

◆ createFolderObject()

Folder TYPO3\CMS\Core\Resource\ResourceFactory::createFolderObject ( ResourceStorage  $storage,
  $identifier,
  $name 
)

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

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

it is recommended to access the ResourceStorage object directly and access ->getFolder($identifier) this method is kept for backwards compatibility

Definition at line 193 of file ResourceFactory.php.

◆ createStorageObject()

ResourceStorage TYPO3\CMS\Core\Resource\ResourceFactory::createStorageObject ( array  $storageRecord,
?array  $storageConfiguration = null 
)

Creates a storage object from a storage database row.

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

It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer

Definition at line 179 of file ResourceFactory.php.

◆ getCollectionObject()

Collection AbstractFileCollection TYPO3\CMS\Core\Resource\ResourceFactory::getCollectionObject (   $uid,
array  $recordData = [] 
)

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

Parameters
int$uid‪The uid of the collection to instantiate.
array$recordData‪The record row from database.
Exceptions

Definition at line 125 of file ResourceFactory.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\createCollectionObject(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

◆ getDefaultStorage()

ResourceStorage null TYPO3\CMS\Core\Resource\ResourceFactory::getDefaultStorage ( )

Returns the Default Storage

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.

Returns
‪ResourceStorage|null

It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer

Definition at line 74 of file ResourceFactory.php.

◆ getFileIndexRepository()

FileIndexRepository TYPO3\CMS\Core\Resource\ResourceFactory::getFileIndexRepository ( )
protected

Returns an instance of the FileIndexRepository

Returns
‪FileIndexRepository

Definition at line 521 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject().

◆ getFileObject()

◆ getFileObjectByStorageAndIdentifier()

File ProcessedFile null TYPO3\CMS\Core\Resource\ResourceFactory::getFileObjectByStorageAndIdentifier (   $storage,
$fileIdentifier 
)

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

Parameters
ResourceStorage | int$storage
string$fileIdentifier
Returns
‪File|ProcessedFile|null

It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer

Definition at line 263 of file ResourceFactory.php.

◆ getFileObjectFromCombinedIdentifier()

File ProcessedFile null TYPO3\CMS\Core\Resource\ResourceFactory::getFileObjectFromCombinedIdentifier (   $identifier)

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

Parameters
string$identifier
Returns
‪File|ProcessedFile|null
Exceptions

Definition at line 234 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Resource\ResourceStorage\renameFile(), TYPO3\CMS\Core\LinkHandling\FileLinkHandler\resolveFile(), and TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject().

◆ getFileReferenceData()

array null TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceData (   $uid,
  $raw = false 
)
protected

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

Parameters
int$uid‪The uid of the file usage (sys_file_reference) to be fetched
bool$raw‪Whether to get raw results without performing overlays
Returns
‪array|null

Definition at line 490 of file ResourceFactory.php.

References $GLOBALS, TYPO3\CMS\Core\Http\ApplicationType\fromRequest(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Core\Resource\ResourceFactory\getFileReferenceObject().

◆ getFileReferenceObject()

FileReference TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceObject (   $uid,
array  $fileReferenceData = [],
  $raw = false 
)

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

Parameters
int$uid‪The uid of the file usage (sys_file_reference) to instantiate.
array$fileReferenceData‪The record row from database.
bool$raw‪Whether to get raw results without performing overlays
Returns
FileReference
Exceptions

Definition at line 445 of file ResourceFactory.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\createFileReferenceObject(), and TYPO3\CMS\Core\Resource\ResourceFactory\getFileReferenceData().

◆ getFolderObjectFromCombinedIdentifier()

Folder TYPO3\CMS\Core\Resource\ResourceFactory::getFolderObjectFromCombinedIdentifier (   $identifier)

◆ getObjectFromCombinedIdentifier()

FileInterface Folder TYPO3\CMS\Core\Resource\ResourceFactory::getObjectFromCombinedIdentifier (   $identifier)

◆ getStorageObject()

ResourceStorage TYPO3\CMS\Core\Resource\ResourceFactory::getStorageObject (   $uid,
array  $recordData = [],
$fileIdentifier = null 
)

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

Parameters
int | null$uid‪The uid of the storage to instantiate.
array$recordData‪The record row from database.
string$fileIdentifier‪Identifier for a file. Used for auto-detection of a storage, but only if $uid === 0 (Local default storage) is used
Exceptions

Definition at line 91 of file ResourceFactory.php.

◆ getStorageObjectFromCombinedIdentifier()

ResourceStorage TYPO3\CMS\Core\Resource\ResourceFactory::getStorageObjectFromCombinedIdentifier (   $identifier)

Gets a storage object from a combined identifier

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

It is recommended to use the StorageRepository in the future, and this is only kept as backwards-compat layer

Definition at line 376 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ retrieveFileOrFolderObject()

File Folder null TYPO3\CMS\Core\Resource\ResourceFactory::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|null

Definition at line 291 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Utility\PathUtility\dirname(), TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath(), TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject(), TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectFromCombinedIdentifier(), TYPO3\CMS\Core\Resource\ResourceFactory\getFolderObjectFromCombinedIdentifier(), TYPO3\CMS\Core\Resource\ResourceFactory\getObjectFromCombinedIdentifier(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), TYPO3\CMS\Core\Utility\PathUtility\getPublicResourceWebPath(), and TYPO3\CMS\Core\Utility\PathUtility\getRelativePath().

Referenced by TYPO3\CMS\Core\LinkHandling\LegacyLinkNotationConverter\getFileOrFolderObjectFromMixedIdentifier(), TYPO3\CMS\Core\Tests\Unit\Resource\ResourceFactoryTest\retrieveFileOrFolderObjectCallsGetFolderObjectFromCombinedIdentifierWithAbsolutePath(), and TYPO3\CMS\Core\Tests\Unit\Resource\ResourceFactoryTest\retrieveFileOrFolderObjectCallsGetFolderObjectFromCombinedIdentifierWithRelativePath().

Member Data Documentation

◆ $collectionInstances

array<int,CollectionInterface<File> > TYPO3\CMS\Core\Resource\ResourceFactory::$collectionInstances = array( )
protected

Definition at line 44 of file ResourceFactory.php.

◆ $fileInstances

File [] TYPO3\CMS\Core\Resource\ResourceFactory::$fileInstances = array( )
protected

Definition at line 48 of file ResourceFactory.php.

◆ $fileReferenceInstances

FileReference [] TYPO3\CMS\Core\Resource\ResourceFactory::$fileReferenceInstances = array( )
protected

Definition at line 52 of file ResourceFactory.php.

◆ $storageRepository

StorageRepository TYPO3\CMS\Core\Resource\ResourceFactory::$storageRepository
protected