Attention
TYPO3 v9 has reached its end-of-life September 30th, 2021 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.
You can order Extended Long Term Support (ELTS) here: TYPO3 ELTS.
The ResourceFactory Class¶
The \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\Resource\ResourceFactory::getInstance();
$storage = $resourceFactory->getDefaultStorage();
Note
This may return null
if no default Storage exists.
Getting any Storage¶
The ResourceFactory
should also be used when retrieving
any Storage. You should not try to instantiate directly a
\TYPO3\CMS\Core\Resource\StorageRepository
and call
its findByUid()
method.
$resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
$storage = $resourceFactory->getStorageObject(3);