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

Public Member Functions

Driver DriverInterface getDriverObject ($driverIdentificationString, array $driverConfiguration)
 
ResourceStorage null getDefaultStorage ()
 
ResourceStorage getStorageObject ($uid, array $recordData=[], &$fileIdentifier=null)
 
array convertFlexFormDataToConfigurationArray ($flexFormData)
 
Collection AbstractFileCollection getCollectionObject ($uid, array $recordData=[])
 
Collection AbstractFileCollection createCollectionObject (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 ($storageUid, &$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)
 

Static Public Member Functions

static ResourceFactory getInstance ()
 

Protected Member Functions

int findBestMatchingStorageByLocalPath (&$localPath)
 
 initializeLocalStorageCache ()
 
array null getFileReferenceData ($uid, $raw=false)
 
FileIndexRepository getFileIndexRepository ()
 
ProcessedFileRepository getProcessedFileRepository ()
 
Index Indexer getIndexer (ResourceStorage $storage)
 

Protected Attributes

ResourceStorage[] $storageInstances = array( )
 
Collection AbstractFileCollection[] $collectionInstances = array( )
 
File[] $fileInstances = array( )
 
FileReference[] $fileReferenceInstances = array( )
 
array< int, $localDriverStorageCache;protected EventDispatcherInterface $eventDispatcher;public function __construct(EventDispatcherInterface $eventDispatcher) { $this-> eventDispatcher = $eventDispatcher
 

Additional Inherited Members

- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Resource\ResourceFactoryInterface
const SIGNAL_PreProcessStorage = 'preProcessStorage'
 
const SIGNAL_PostProcessStorage = 'postProcessStorage'
 

Detailed Description

Factory class for FAL objects

Definition at line 40 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

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

Definition at line 283 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceStorage\__construct(), and TYPO3\CMS\Core\Resource\ResourceFactory\createStorageObject().

◆ createCollectionObject()

Collection AbstractFileCollection 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
Collection\AbstractFileCollection

Definition at line 338 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$storage
Returns
File

Definition at line 594 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), and TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject().

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 652 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

Definition at line 374 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount(), TYPO3\CMS\Core\Resource\ResourceStorage\getFolder(), TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolder(), TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders(), and TYPO3\CMS\Core\Resource\ResourceStorage\getRootLevelFolder().

◆ 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$storageConfiguration‪Storage configuration (if given, this won't be extracted from the FlexForm value but the supplied array used instead)
Returns
ResourceStorage

Definition at line 356 of file ResourceFactory.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\convertFlexFormDataToConfigurationArray(), TYPO3\CMS\Core\Resource\ResourceFactory\eventDispatcher, and TYPO3\CMS\Core\Resource\ResourceFactory\getDriverObject().

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

◆ findBestMatchingStorageByLocalPath()

int TYPO3\CMS\Core\Resource\ResourceFactory::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 fileadmin in public web path.

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

Parameters
string$localPath
Returns
‪int

Definition at line 200 of file ResourceFactory.php.

References TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath(), TYPO3\CMS\Core\Utility\PathUtility\getCommonPrefix(), and TYPO3\CMS\Core\Resource\ResourceFactory\initializeLocalStorageCache().

Referenced by TYPO3\CMS\Core\Tests\Unit\Resource\ResourceFactoryTest\findBestMatchingStorageByLocalPathReturnsDefaultStorageIfNoMatchIsFound(), and TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject().

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

References TYPO3\CMS\Core\Resource\ResourceFactory\createCollectionObject().

◆ 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

Definition at line 115 of file ResourceFactory.php.

◆ getDriverObject()

Driver DriverInterface TYPO3\CMS\Core\Resource\ResourceFactory::getDriverObject (   $driverIdentificationString,
array  $driverConfiguration 
)

Creates a driver object for a specified storage object.

Parameters
string$driverIdentificationString‪The driver class (or identifier) to use.
array$driverConfiguration‪The configuration of the storage
Returns
Driver\DriverInterface
Exceptions

Definition at line 96 of file ResourceFactory.php.

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

◆ getFileIndexRepository()

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

◆ getFileObject()

◆ getFileObjectByStorageAndIdentifier()

◆ getFileObjectFromCombinedIdentifier()

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

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

References $GLOBALS, and TYPO3\CMS\Backend\Utility\BackendUtility\getRecordWSOL().

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 620 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)

◆ getIndexer()

Index Indexer TYPO3\CMS\Core\Resource\ResourceFactory::getIndexer ( ResourceStorage  $storage)
protected

Returns an instance of the Indexer

Parameters
ResourceStorage$storage
Returns
Index\Indexer

Definition at line 715 of file ResourceFactory.php.

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

◆ getInstance()

static ResourceFactory TYPO3\CMS\Core\Resource\ResourceFactory::getInstance ( )
static

Gets a singleton instance of this class.

Returns
ResourceFactory
Deprecated:
‪use regular DI or - if not possible - GeneralUtility::makeInstance instead, as this Factory does not serve any purpose

Definition at line 48 of file ResourceFactory.php.

◆ getObjectFromCombinedIdentifier()

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

◆ getProcessedFileRepository()

ProcessedFileRepository TYPO3\CMS\Core\Resource\ResourceFactory::getProcessedFileRepository ( )
protected

◆ getStorageObject()

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

◆ 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

Definition at line 558 of file ResourceFactory.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ initializeLocalStorageCache()

TYPO3\CMS\Core\Resource\ResourceFactory::initializeLocalStorageCache ( )
protected

Creates an array mapping all uids to the basePath of storages using the "local" driver.

Definition at line 246 of file ResourceFactory.php.

References TYPO3\CMS\Core\Resource\LocalPath\TYPE_ABSOLUTE, and TYPO3\CMS\Core\Resource\LocalPath\TYPE_RELATIVE.

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

◆ 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 482 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(), 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

Collection AbstractFileCollection [] TYPO3\CMS\Core\Resource\ResourceFactory::$collectionInstances = array( )
protected

Definition at line 60 of file ResourceFactory.php.

◆ $fileInstances

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

Definition at line 64 of file ResourceFactory.php.

◆ $fileReferenceInstances

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

Definition at line 68 of file ResourceFactory.php.

◆ $storageInstances

ResourceStorage [] TYPO3\CMS\Core\Resource\ResourceFactory::$storageInstances = array( )
protected

Definition at line 56 of file ResourceFactory.php.

◆ eventDispatcher

array<int, $localDriverStorageCache; protected EventDispatcherInterface $eventDispatcher; public function __construct(EventDispatcherInterface $eventDispatcher) { $this-> TYPO3\CMS\Core\Resource\ResourceFactory::eventDispatcher = $eventDispatcher
protected

A list of the base paths of "local" driver storages. Used to make the detection of base paths easier.

LocalPath>|null

Definition at line 85 of file ResourceFactory.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceFactory\createStorageObject(), and TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject().