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