TYPO3 v10 has reached end-of-life as of April 30th 2023 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.
The ResourceFactory Class¶
\TYPO3\CMS\Core\Resource\ResourceFactory is the
workhorse of the File Abstraction Layer from a coding point
of view. It contains a number of utility methods, some of
which are described here, some others which appear in the
other code samples provided in this chapter.
Getting the Default Storage¶
Of all available Storages, one may be marked as default. This is the Storage that will be used for any operation whenever no Storage has been explicitly chosen or defined (for example, when not using a combined identifier).
$resourceFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class); $storage = $resourceFactory->getDefaultStorage();
This may return
null if no default Storage exists.
Getting any Storage¶
ResourceFactory should also be used when retrieving
any Storage. You should not try to instantiate directly a
\TYPO3\CMS\Core\Resource\StorageRepository and call
$resourceFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class); $storage = $resourceFactory->getStorageObject(3);