‪TYPO3CMS  11.5
TYPO3\CMS\Core\Resource\StorageRepository Class Reference
Inheritance diagram for TYPO3\CMS\Core\Resource\StorageRepository:

Public Member Functions

ResourceStorage null getDefaultStorage ()
 
 findByUid (int $uid)
 
ResourceStorage null findByCombinedIdentifier (string $identifier)
 
 flush ()
 
ResourceStorage[] findByStorageType ($storageType)
 
ResourceStorage[] findAll ()
 
int createLocalStorage ($name, $basePath, $pathType, $description='', $default=false)
 
ResourceStorage getStorageObject ($uid, array $recordData=[], &$fileIdentifier=null)
 
ResourceStorage createStorageObject (array $storageRecord, array $storageConfiguration=null)
 
ResourceStorage createFromRecord (array $storageRecord)
 

Public Attributes

$this driverRegistry = $driverRegistry
 

Protected Member Functions

array fetchRecordDataByUid (int $uid)
 
 initializeLocalCache ()
 
bool testCaseSensitivity ($absolutePath)
 
int findBestMatchingStorageByLocalPath (&$localPath)
 
 initializeLocalStorageCache ()
 
array convertFlexFormDataToConfigurationArray (string $flexFormData)
 
DriverInterface getDriverObject (string $driverIdentificationString, array $driverConfiguration)
 

Protected Attributes

array null $storageRowCache
 
array< int, $localDriverStorageCache;protected string $table='sys_file_storage';protected DriverRegistry $driverRegistry;protected EventDispatcherInterface $eventDispatcher;protected ResourceStorage[]|null $storageInstances;public function __construct(EventDispatcherInterface $eventDispatcher, DriverRegistry $driverRegistry) { $this-> eventDispatcher = $eventDispatcher
 

Detailed Description

Repository for accessing the file storages

Definition at line 37 of file StorageRepository.php.

Member Function Documentation

◆ convertFlexFormDataToConfigurationArray()

array TYPO3\CMS\Core\Resource\StorageRepository::convertFlexFormDataToConfigurationArray ( string  $flexFormData)
protected

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 487 of file StorageRepository.php.

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

◆ createFromRecord()

ResourceStorage TYPO3\CMS\Core\Resource\StorageRepository::createFromRecord ( array  $storageRecord)
Parameters
array$storageRecord
Returns
ResourceStorage

Definition at line 515 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\createStorageObject().

◆ createLocalStorage()

int TYPO3\CMS\Core\Resource\StorageRepository::createLocalStorage (   $name,
  $basePath,
  $pathType,
  $description = '',
  $default = false 
)

Create the initial local storage base e.g. for the fileadmin/ directory.

Parameters
string$name
string$basePath
string$pathType
string$description
bool$default‪set to default storage
Returns
‪int uid of the inserted record

Definition at line 245 of file StorageRepository.php.

References $GLOBALS, TYPO3\CMS\Core\Resource\StorageRepository\flush(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), and TYPO3\CMS\Core\Resource\StorageRepository\testCaseSensitivity().

Referenced by TYPO3\CMS\Core\Resource\StorageRepository\initializeLocalCache().

◆ createStorageObject()

ResourceStorage TYPO3\CMS\Core\Resource\StorageRepository::createStorageObject ( array  $storageRecord,
array  $storageConfiguration = null 
)

Creates a storage object from a storage database row.

Parameters
array$storageRecord
array | null$storageConfiguration‪Storage configuration (if given, this won't be extracted from the FlexForm value but the supplied array used instead)
Returns
ResourceStorage

this method is only public for having access to ResourceFactory->createStorageObject(). In TYPO3 v12 this method can be changed to protected again.

Definition at line 470 of file StorageRepository.php.

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

Referenced by TYPO3\CMS\Impexp\Import\checkImportPrerequisites(), TYPO3\CMS\Core\Resource\StorageRepository\createFromRecord(), and TYPO3\CMS\Core\Resource\StorageRepository\getStorageObject().

◆ fetchRecordDataByUid()

array TYPO3\CMS\Core\Resource\StorageRepository::fetchRecordDataByUid ( int  $uid)
protected

◆ findAll()

ResourceStorage [] TYPO3\CMS\Core\Resource\StorageRepository::findAll ( )

Returns a list of mountpoints that are available in the VFS. In case no storage exists this automatically created a storage for fileadmin/

Returns
ResourceStorage[]

Definition at line 220 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\driverRegistry, TYPO3\CMS\Core\Resource\StorageRepository\getStorageObject(), and TYPO3\CMS\Core\Resource\StorageRepository\initializeLocalCache().

Referenced by TYPO3\CMS\Impexp\ImportExport\fetchStorages(), and TYPO3\CMS\Core\Resource\StorageRepository\getDefaultStorage().

◆ findBestMatchingStorageByLocalPath()

int TYPO3\CMS\Core\Resource\StorageRepository::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 390 of file StorageRepository.php.

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

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

◆ findByCombinedIdentifier()

ResourceStorage null TYPO3\CMS\Core\Resource\StorageRepository::findByCombinedIdentifier ( string  $identifier)

Gets a storage object from a combined identifier

Parameters
string$identifier‪An identifier of the form [storage uid]:[object identifier]
Returns
‪ResourceStorage|null

Definition at line 107 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\findByUid(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ findByStorageType()

ResourceStorage [] TYPO3\CMS\Core\Resource\StorageRepository::findByStorageType (   $storageType)

◆ findByUid()

◆ flush()

TYPO3\CMS\Core\Resource\StorageRepository::flush ( )

Flush the internal storage caches to force reloading of storages with the next fetch.

Definition at line 183 of file StorageRepository.php.

Referenced by TYPO3\CMS\Core\Resource\StorageRepository\createLocalStorage(), TYPO3\CMS\Impexp\ImportExport\fetchStorages(), and TYPO3\CMS\Core\Resource\StorageRepository\initializeLocalCache().

◆ getDefaultStorage()

ResourceStorage null TYPO3\CMS\Core\Resource\StorageRepository::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 81 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\findAll().

◆ getDriverObject()

DriverInterface TYPO3\CMS\Core\Resource\StorageRepository::getDriverObject ( string  $driverIdentificationString,
array  $driverConfiguration 
)
protected

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
‪DriverInterface

Definition at line 502 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\driverRegistry.

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

◆ getStorageObject()

ResourceStorage TYPO3\CMS\Core\Resource\StorageRepository::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$uid‪The uid of the storage to instantiate.
array$recordData‪The record row from database.
mixed | null$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 332 of file StorageRepository.php.

References TYPO3\CMS\Core\Resource\StorageRepository\createStorageObject(), TYPO3\CMS\Core\Resource\StorageRepository\eventDispatcher, TYPO3\CMS\Core\Resource\StorageRepository\fetchRecordDataByUid(), TYPO3\CMS\Core\Resource\StorageRepository\findBestMatchingStorageByLocalPath(), and TYPO3\CMS\Core\Core\Environment\getPublicPath().

Referenced by TYPO3\CMS\Core\Resource\StorageRepository\findAll(), TYPO3\CMS\Core\Resource\StorageRepository\findByStorageType(), and TYPO3\CMS\Core\Resource\StorageRepository\findByUid().

◆ initializeLocalCache()

◆ initializeLocalStorageCache()

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

◆ testCaseSensitivity()

bool TYPO3\CMS\Core\Resource\StorageRepository::testCaseSensitivity (   $absolutePath)
protected

Test if the local filesystem is case sensitive

Parameters
string$absolutePath
Returns
‪bool

Definition at line 295 of file StorageRepository.php.

Referenced by TYPO3\CMS\Core\Resource\StorageRepository\createLocalStorage().

Member Data Documentation

◆ $storageRowCache

array null TYPO3\CMS\Core\Resource\StorageRepository::$storageRowCache
protected

Definition at line 43 of file StorageRepository.php.

◆ driverRegistry

$this TYPO3\CMS\Core\Resource\StorageRepository::driverRegistry = $driverRegistry

◆ eventDispatcher

array<int, $localDriverStorageCache; protected string $table = 'sys_file_storage'; protected DriverRegistry $driverRegistry; protected EventDispatcherInterface $eventDispatcher; protected ResourceStorage[]|null $storageInstances; public function __construct(EventDispatcherInterface $eventDispatcher, DriverRegistry $driverRegistry) { $this-> TYPO3\CMS\Core\Resource\StorageRepository::eventDispatcher = $eventDispatcher
protected