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

Public Member Functions

 __construct (protected readonly 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)
 
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)
 
 getFileReferenceObject (int $uid, array $fileReferenceData=[], bool $raw=false)
 
 createFileReferenceObject (array $fileReferenceData)
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Factory class for FAL objects

Definition at line 41 of file ResourceFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 56 of file ResourceFactory.php.

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 103 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 158 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.

Returns
File

Definition at line 402 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()

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.

Definition at line 448 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 177 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$identifier.

◆ 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 122 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$uid, 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 71 of file ResourceFactory.php.

◆ getFileIndexRepository()

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

Returns an instance of the FileIndexRepository

Returns
‪FileIndexRepository

Definition at line 495 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 247 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 218 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

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

◆ getFileReferenceData()

array null TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceData ( int  $uid,
bool  $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 460 of file ResourceFactory.php.

References $GLOBALS, TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\Http\fromRequest, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

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

◆ getFileReferenceObject()

TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceObject ( int  $uid,
array  $fileReferenceData = [],
bool  $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
Exceptions
Exception

Definition at line 425 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\Resource\ResourceFactory\createFileReferenceObject(), and TYPO3\CMS\Core\Resource\ResourceFactory\getFileReferenceData().

◆ getFolderObjectFromCombinedIdentifier()

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

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

@TODO check naming, inserted by SteffenR while working on filelist

Parameters
string$identifier
Returns
Folder

Definition at line 331 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$identifier, TYPO3\CMS\Core\Core\Environment\getPublicPath(), TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

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

◆ 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 88 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$uid.

◆ 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 360 of file ResourceFactory.php.

References TYPO3\CMS\Webhooks\Message\$identifier, 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 275 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\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 45 of file ResourceFactory.php.

◆ $fileInstances

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

Definition at line 49 of file ResourceFactory.php.

◆ $fileReferenceInstances

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

Definition at line 54 of file ResourceFactory.php.