LocalDriver extends AbstractHierarchicalFilesystemDriver implements StreamableDriverInterface

A concrete implementation for a File Driver for the local file system.

Table of Contents

Interfaces

StreamableDriverInterface
An interface FAL drivers have to implement to fulfil the needs of streaming files using PSR-7 Response objects.

Constants

UNSAFE_FILENAME_CHARACTER_EXPRESSION  = '\x00-\x2C\/\x3A-\x3F\x5B-\x60\x7B-\xBF'

Properties

$absoluteBasePath  : string
The absolute base path. It always contains a trailing slash.
$baseUri  : string|null
The base URL that points to this driver's storage. As long is this is not set, it is assumed that this folder is not publicly available
$capabilities  : Capabilities
The capabilities of this driver. This value should be set in the constructor of derived classes.
$configuration  : array<string|int, mixed>
The configuration of this driver
$mappingFolderNameToRole  : array<non-empty-string, FolderInterface::ROLE_*>
$storageUid  : int|null
The storage uid the driver was instantiated for
$supportedHashAlgorithms  : array<string|int, mixed>
A list of all supported hash algorithms, written all lower case.

Methods

__construct()  : mixed
Creates this object.
addFile()  : non-empty-string
Adds a file from the local server's hard drive to a given path in TYPO3s storage location.
copyFileWithinStorage()  : non-empty-string
Copies a file *within* the current storage.
copyFolderWithinStorage()  : true
Folder equivalent to copyFileWithinStorage().
countFilesInFolder()  : int<0, max>
Returns the number of files inside the specified path.
countFoldersInFolder()  : int<0, max>
Returns the number of folders inside the specified path.
createFile()  : non-empty-string
Creates a new (empty) file and returns the identifier.
createFolder()  : non-empty-string
Creates a folder, within a given parent folder.
deleteFile()  : bool
Removes a file from the filesystem. This does not check if the file is still used or if it is a bad idea to delete it for some other reason this has to be taken care of in the upper layers (e.g. the ResourceStorage).
deleteFolder()  : bool
Removes a folder from the hard drive.
dumpFileContents()  : void
Directly output the contents of the file to the output buffer.
fileExists()  : bool
Checks if a file exists on the file system.
fileExistsInFolder()  : bool
Checks if a file inside a folder exists.
folderExists()  : bool
Checks if a folder exists.
folderExistsInFolder()  : bool
Checks if a folder inside a folder exists.
getCapabilities()  : Capabilities
Returns the capabilities of this driver.
getDefaultFolder()  : non-empty-string
Returns the identifier of the default folder where new files should be put into.
getFileContents()  : string
Returns the contents of a file. Beware that this requires to load the complete file into memory and also may require fetching the file from an external location. So this might be an expensive operation (both in terms of processing resources and money) for large files.
getFileForLocalProcessing()  : non-empty-string
Returns (a local copy of) a file for further processing. This makes a copy first when in writable mode, so if you change the file, you have to update it yourself afterward.
getFileInfoByIdentifier()  : array<non-empty-string, mixed>
Returns information about a file.
getFileInFolder()  : non-empty-string
Returns a file inside the specified path.
getFilesInFolder()  : array<string|int, string>
Returns a list of files inside the specified path.
getFolderInfoByIdentifier()  : array{identifier: non-empty-string, name: string, mtime: int, ctime: int, storage: int}
Returns information about a folder.
getFolderInFolder()  : non-empty-string
Returns the identifier for a folder within a given folder.
getFoldersInFolder()  : array<string|int, string>
Returns a list of folders inside the specified path.
getParentFolderIdentifierOfIdentifier()  : non-empty-string
Returns the identifier of the folder the file resides in.
getPermissions()  : array{r: bool, w: bool}
Returns the permissions of a file/folder as an array (keys r, w) of boolean flags.
getPublicUrl()  : string|null
Returns a publicly accessible URL to a file or folder.
getRole()  : string
Returns the role of an item. This is currently only implemented for folder, but could be extended to files as well.
getRootLevelFolder()  : non-empty-string
Returns the identifier of the root level folder of the storage.
getSpecificFileInformation()  : bool|int|string|null
Extracts specific information of a file from the file system.
hasCapability()  : bool
Returns TRUE if this driver has the given capability.
hash()  : string
Creates a (cryptographic) hash for a file.
hashIdentifier()  : non-empty-string
Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.
initialize()  : void
Initializes this object. This is called by the storage after the driver has been attached.
isCaseSensitiveFileSystem()  : bool
Returns TRUE if this driver uses case-sensitive identifiers. NOTE: This is a configurable setting, but the setting does not change the way the underlying file system treats the identifiers; the setting should therefore always reflect the file system and not try to change its behaviour
isFolderEmpty()  : bool
Checks if a folder contains files and (if supported) other folders.
isWithin()  : bool
Checks if a given identifier is within a container, e.g. if a file or folder is within another folder. It will also return TRUE if both canonical identifiers are equal.
mergeConfigurationCapabilities()  : Capabilities
Merges the capabilities from the user of the storage configuration into the actual capabilities of the driver and returns the result.
moveFileWithinStorage()  : non-empty-string
Moves a file *within* the current storage.
moveFolderWithinStorage()  : array<non-empty-string, non-empty-string>
Folder equivalent to moveFileWithinStorage().
processConfiguration()  : void
Processes the configuration for this driver.
renameFile()  : non-empty-string
Renames a file in this storage.
renameFolder()  : array<string, string>
Renames a folder in this storage.
replaceFile()  : bool
Replaces the contents (and file-specific metadata) of a file with another file from the server's hard disk.
sanitizeFileName()  : non-empty-string
Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' Trailing dots are removed
setFileContents()  : int<0, max>
Sets the contents of a file to the specified value.
setStorageUid()  : void
Sets the storage uid the driver belongs to
streamFile()  : ResponseInterface
Stream file using a PSR-7 Response object.
applyFilterMethodsToDirectoryItem()  : bool
Applies a set of filter methods to a file name to find out if it should be used or not.
calculateBasePath()  : string
Calculates the absolute path to this driver's storage location
canonicalizeAndCheckFileIdentifier()  : string
Makes sure the Path given as parameter is valid.
canonicalizeAndCheckFilePath()  : string
Makes sure the given path is valid.
canonicalizeAndCheckFolderIdentifier()  : string
Makes sure the Path given as parameter is valid.
copyFileToTemporaryPath()  : string
Copies a file to a temporary path and returns that path.
createIdentifierMap()  : array<non-empty-string, non-empty-string>
Creates a map of old and new file/folder identifiers after renaming or moving a folder. The old identifier is used as the key, the new one as the value.
determineBaseUrl()  : void
Determines the base URL for this driver, from the configuration or the public path.
extractFileInformation()  : array<string|int, mixed>
Extracts information about a file from the filesystem.
getAbsoluteBasePath()  : string
Returns the absolute path of the folder this driver operates on.
getAbsolutePath()  : string
Returns the absolute path of a file or folder.
getDirectoryItemList()  : array<string|int, string>
Generic wrapper for extracting a list of items from a path.
getRecycleDirectory()  : string
Get the path of the nearest recycler folder of a given path.
getTemporaryPathForFile()  : string
Returns a temporary path for a given file, including the file extension.
isAllowedAbsolutePath()  : bool
Wrapper for `GeneralUtility::isAllowedAbsPath`, which implicitly invokes `GeneralUtility::validPathStr` (like in `parent::isPathValid`).
isPathValid()  : bool
Wrapper for \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr()
isValidFilename()  : bool
Checks a fileName for validity. This could be overridden in concrete drivers if they have different file naming rules.
recycleFileOrFolder()  : bool
Moves a file or folder to the given directory, renaming the source in the process if a file or folder of the same name already exists in the target path.
retrieveFileAndFoldersInPath()  : array<string|int, mixed>
Returns a list with the names of all files and folders in a path, optionally recursive.
sortDirectoryEntries()  : array<string|int, mixed>
Sort the directory entries by a certain key.

Constants

UNSAFE_FILENAME_CHARACTER_EXPRESSION

public string UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\x00-\x2C\/\x3A-\x3F\x5B-\x60\x7B-\xBF'

Properties

$absoluteBasePath

The absolute base path. It always contains a trailing slash.

protected string $absoluteBasePath = '/'

$baseUri

The base URL that points to this driver's storage. As long is this is not set, it is assumed that this folder is not publicly available

protected string|null $baseUri = null

$capabilities

The capabilities of this driver. This value should be set in the constructor of derived classes.

protected Capabilities $capabilities

$configuration

The configuration of this driver

protected array<string|int, mixed> $configuration = []

$mappingFolderNameToRole

protected array<non-empty-string, FolderInterface::ROLE_*> $mappingFolderNameToRole = ['_recycler_' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_RECYCLER, '_temp_' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_TEMPORARY, 'user_upload' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_USERUPLOAD]

$storageUid

The storage uid the driver was instantiated for

protected int|null $storageUid = null

$supportedHashAlgorithms

A list of all supported hash algorithms, written all lower case.

protected array<string|int, mixed> $supportedHashAlgorithms = ['sha1', 'md5']

Methods

__construct()

Creates this object.

public __construct([array<string|int, mixed> $configuration = [] ]) : mixed
Parameters
$configuration : array<string|int, mixed> = []

addFile()

Adds a file from the local server's hard drive to a given path in TYPO3s storage location.

public addFile(non-empty-string $localFilePath, non-empty-string $targetFolderIdentifier[, string $newFileName = '' ][, bool $removeOriginal = true ]) : non-empty-string

This assumes that the local file exists, so no further check is done here. After a successful "add" operation, the original file must not exist anymore.

Parameters
$localFilePath : non-empty-string

within public web path

$targetFolderIdentifier : non-empty-string
$newFileName : string = ''

optional, if not given original name is used

$removeOriginal : bool = true

if set the original file will be removed after successful operation

Return values
non-empty-string

the identifier of the new file

copyFileWithinStorage()

Copies a file *within* the current storage.

public copyFileWithinStorage(non-empty-string $fileIdentifier, non-empty-string $targetFolderIdentifier, non-empty-string $fileName) : non-empty-string

The responsibility of this method in the Driver is only about an intra-storage copy action, where a file is just copied to another folder in the same storage.

Parameters
$fileIdentifier : non-empty-string
$targetFolderIdentifier : non-empty-string
$fileName : non-empty-string
Return values
non-empty-string

the identifier of the new file

copyFolderWithinStorage()

Folder equivalent to copyFileWithinStorage().

public copyFolderWithinStorage(non-empty-string $sourceFolderIdentifier, non-empty-string $targetFolderIdentifier, non-empty-string $newFolderName) : true
Parameters
$sourceFolderIdentifier : non-empty-string
$targetFolderIdentifier : non-empty-string
$newFolderName : non-empty-string
Return values
true

countFilesInFolder()

Returns the number of files inside the specified path.

public countFilesInFolder(non-empty-string $folderIdentifier[, bool $recursive = false ][, array<int, callable> $filenameFilterCallbacks = [] ]) : int<0, max>
Parameters
$folderIdentifier : non-empty-string
$recursive : bool = false
$filenameFilterCallbacks : array<int, callable> = []

callbacks for filtering the items

Return values
int<0, max>

Number of files in folder

countFoldersInFolder()

Returns the number of folders inside the specified path.

public countFoldersInFolder(non-empty-string $folderIdentifier[, bool $recursive = false ][, array<int, callable> $folderNameFilterCallbacks = [] ]) : int<0, max>
Parameters
$folderIdentifier : non-empty-string
$recursive : bool = false
$folderNameFilterCallbacks : array<int, callable> = []

callbacks for filtering the items

Return values
int<0, max>

Number of folders in folder

createFile()

Creates a new (empty) file and returns the identifier.

public createFile(non-empty-string $fileName, non-empty-string $parentFolderIdentifier) : non-empty-string
Parameters
$fileName : non-empty-string
$parentFolderIdentifier : non-empty-string
Return values
non-empty-string

createFolder()

Creates a folder, within a given parent folder.

public createFolder(non-empty-string $newFolderName[, string $parentFolderIdentifier = '' ][, bool $recursive = false ]) : non-empty-string

If no parent folder is given, a folder on the root-level will be created

Parameters
$newFolderName : non-empty-string
$parentFolderIdentifier : string = ''
$recursive : bool = false
Return values
non-empty-string

the identifier of the new folder

deleteFile()

Removes a file from the filesystem. This does not check if the file is still used or if it is a bad idea to delete it for some other reason this has to be taken care of in the upper layers (e.g. the ResourceStorage).

public deleteFile(non-empty-string $fileIdentifier) : bool
Parameters
$fileIdentifier : non-empty-string
Return values
bool

deleteFolder()

Removes a folder from the hard drive.

public deleteFolder(non-empty-string $folderIdentifier[, bool $deleteRecursively = false ]) : bool
Parameters
$folderIdentifier : non-empty-string
$deleteRecursively : bool = false
Return values
bool

dumpFileContents()

Directly output the contents of the file to the output buffer.

public dumpFileContents(non-empty-string $identifier) : void

Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.

Parameters
$identifier : non-empty-string

fileExists()

Checks if a file exists on the file system.

public fileExists(non-empty-string $fileIdentifier) : bool
Parameters
$fileIdentifier : non-empty-string
Return values
bool

fileExistsInFolder()

Checks if a file inside a folder exists.

public fileExistsInFolder(non-empty-string $fileName, non-empty-string $folderIdentifier) : bool
Parameters
$fileName : non-empty-string
$folderIdentifier : non-empty-string
Return values
bool

folderExists()

Checks if a folder exists.

public folderExists(non-empty-string $folderIdentifier) : bool
Parameters
$folderIdentifier : non-empty-string
Return values
bool

folderExistsInFolder()

Checks if a folder inside a folder exists.

public folderExistsInFolder(non-empty-string $folderName, non-empty-string $folderIdentifier) : bool
Parameters
$folderName : non-empty-string
$folderIdentifier : non-empty-string
Return values
bool

getDefaultFolder()

Returns the identifier of the default folder where new files should be put into.

public getDefaultFolder() : non-empty-string
Return values
non-empty-string

getFileContents()

Returns the contents of a file. Beware that this requires to load the complete file into memory and also may require fetching the file from an external location. So this might be an expensive operation (both in terms of processing resources and money) for large files.

public getFileContents(non-empty-string $fileIdentifier) : string
Parameters
$fileIdentifier : non-empty-string
Return values
string

The file contents if file exists, otherwise an empty string

getFileForLocalProcessing()

Returns (a local copy of) a file for further processing. This makes a copy first when in writable mode, so if you change the file, you have to update it yourself afterward.

public getFileForLocalProcessing(non-empty-string $fileIdentifier[, bool $writable = true ]) : non-empty-string
Parameters
$fileIdentifier : non-empty-string
$writable : bool = true

Set this to FALSE if you only need the file for read operations. This might speed up things, e.g. by using a cached local version. Never modify the file if you have set this flag!

Return values
non-empty-string

The path to the file on the local disk

getFileInfoByIdentifier()

Returns information about a file.

public getFileInfoByIdentifier(non-empty-string $fileIdentifier[, array<int, non-empty-string> $propertiesToExtract = [] ]) : array<non-empty-string, mixed>
Parameters
$fileIdentifier : non-empty-string

In the case of the LocalDriver, this is the (relative) path to the file.

$propertiesToExtract : array<int, non-empty-string> = []

Array of properties which should be extracted, if empty all will be extracted

Return values
array<non-empty-string, mixed>

getFileInFolder()

Returns a file inside the specified path.

public getFileInFolder(non-empty-string $fileName, non-empty-string $folderIdentifier) : non-empty-string
Parameters
$fileName : non-empty-string
$folderIdentifier : non-empty-string
Return values
non-empty-string

File Identifier

getFilesInFolder()

Returns a list of files inside the specified path.

public getFilesInFolder(string $folderIdentifier[, int $start = 0 ][, int $numberOfItems = 0 ][, bool $recursive = false ][, array<string|int, mixed> $filenameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, string>
Parameters
$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$filenameFilterCallbacks : array<string|int, mixed> = []

The method callbacks to use for filtering the items

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, string>

of FileIdentifiers

getFolderInfoByIdentifier()

Returns information about a folder.

public getFolderInfoByIdentifier(string $folderIdentifier) : array{identifier: non-empty-string, name: string, mtime: int, ctime: int, storage: int}
Parameters
$folderIdentifier : string

In the case of the LocalDriver, this is the (relative) path to the file.

Return values
array{identifier: non-empty-string, name: string, mtime: int, ctime: int, storage: int}

getFolderInFolder()

Returns the identifier for a folder within a given folder.

public getFolderInFolder(non-empty-string $folderName, non-empty-string $folderIdentifier) : non-empty-string
Parameters
$folderName : non-empty-string

The name of the target folder

$folderIdentifier : non-empty-string
Return values
non-empty-string

getFoldersInFolder()

Returns a list of folders inside the specified path.

public getFoldersInFolder(string $folderIdentifier[, int $start = 0 ][, int $numberOfItems = 0 ][, bool $recursive = false ][, array<string|int, mixed> $folderNameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, string>
Parameters
$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$folderNameFilterCallbacks : array<string|int, mixed> = []

The method callbacks to use for filtering the items

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, string>

folder identifiers (where key and value are identical, but int-like identifiers will get converted to int array keys)

getParentFolderIdentifierOfIdentifier()

Returns the identifier of the folder the file resides in.

public getParentFolderIdentifierOfIdentifier(string $fileIdentifier) : non-empty-string
Parameters
$fileIdentifier : string
Tags
phpstan-param

non-empty-string $fileIdentifier

phpstan-return

non-empty-string

Return values
non-empty-string

getPermissions()

Returns the permissions of a file/folder as an array (keys r, w) of boolean flags.

public getPermissions(non-empty-string $identifier) : array{r: bool, w: bool}
Parameters
$identifier : non-empty-string
Return values
array{r: bool, w: bool}

getPublicUrl()

Returns a publicly accessible URL to a file or folder.

public getPublicUrl(non-empty-string $identifier) : string|null

For the local driver, this will always return a path relative to public web path. For non-public storages, this method returns null.

Parameters
$identifier : non-empty-string
Return values
string|null

NULL if file is missing or deleted, the generated url otherwise

getRole()

Returns the role of an item. This is currently only implemented for folder, but could be extended to files as well.

public getRole(string $folderIdentifier) : string
Parameters
$folderIdentifier : string
Return values
string

getRootLevelFolder()

Returns the identifier of the root level folder of the storage.

public getRootLevelFolder() : non-empty-string
Return values
non-empty-string

getSpecificFileInformation()

Extracts specific information of a file from the file system.

public getSpecificFileInformation(string $fileIdentifier, string $containerPath, string $property) : bool|int|string|null
Parameters
$fileIdentifier : string
$containerPath : string
$property : string
Return values
bool|int|string|null

hasCapability()

Returns TRUE if this driver has the given capability.

public hasCapability(int $capability) : bool
Parameters
$capability : int
Tags
phpstan-param

Capabilities::CAPABILITY_* $capability

Return values
bool

hash()

Creates a (cryptographic) hash for a file.

public hash(string $fileIdentifier, string $hashAlgorithm) : string
Parameters
$fileIdentifier : string
$hashAlgorithm : string

The hash algorithm to use

Return values
string

hashIdentifier()

Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.

public hashIdentifier(string $identifier) : non-empty-string
Parameters
$identifier : string
Tags
phpstan-param

non-empty-string $identifier

phpstan-return

non-empty-string

Return values
non-empty-string

initialize()

Initializes this object. This is called by the storage after the driver has been attached.

public initialize() : void

isCaseSensitiveFileSystem()

Returns TRUE if this driver uses case-sensitive identifiers. NOTE: This is a configurable setting, but the setting does not change the way the underlying file system treats the identifiers; the setting should therefore always reflect the file system and not try to change its behaviour

public isCaseSensitiveFileSystem() : bool
Return values
bool

isFolderEmpty()

Checks if a folder contains files and (if supported) other folders.

public isFolderEmpty(non-empty-string $folderIdentifier) : bool
Parameters
$folderIdentifier : non-empty-string
Return values
bool

TRUE if there are no files and folders within $folder

isWithin()

Checks if a given identifier is within a container, e.g. if a file or folder is within another folder. It will also return TRUE if both canonical identifiers are equal.

public isWithin(non-empty-string $folderIdentifier, non-empty-string $identifier) : bool
Parameters
$folderIdentifier : non-empty-string
$identifier : non-empty-string

identifier to be checked against $folderIdentifier

Return values
bool

TRUE if $content is within or matches $folderIdentifier

mergeConfigurationCapabilities()

Merges the capabilities from the user of the storage configuration into the actual capabilities of the driver and returns the result.

public mergeConfigurationCapabilities(Capabilities $capabilities) : Capabilities
Parameters
$capabilities : Capabilities
Return values
Capabilities

moveFileWithinStorage()

Moves a file *within* the current storage.

public moveFileWithinStorage(non-empty-string $fileIdentifier, non-empty-string $targetFolderIdentifier, non-empty-string $newFileName) : non-empty-string

The responsibility of this method in the Driver is only about an intra-storage move action, where a file is just moved to another folder in the same storage.

Parameters
$fileIdentifier : non-empty-string
$targetFolderIdentifier : non-empty-string
$newFileName : non-empty-string
Return values
non-empty-string

moveFolderWithinStorage()

Folder equivalent to moveFileWithinStorage().

public moveFolderWithinStorage(non-empty-string $sourceFolderIdentifier, non-empty-string $targetFolderIdentifier, non-empty-string $newFolderName) : array<non-empty-string, non-empty-string>
Parameters
$sourceFolderIdentifier : non-empty-string
$targetFolderIdentifier : non-empty-string
$newFolderName : non-empty-string
Return values
array<non-empty-string, non-empty-string>

A map of old to new file identifiers

processConfiguration()

Processes the configuration for this driver.

public processConfiguration() : void

renameFile()

Renames a file in this storage.

public renameFile(non-empty-string $fileIdentifier, non-empty-string $newName) : non-empty-string
Parameters
$fileIdentifier : non-empty-string
$newName : non-empty-string

The target path (including the file name!)

Return values
non-empty-string

The identifier of the file after renaming

renameFolder()

Renames a folder in this storage.

public renameFolder(non-empty-string $folderIdentifier, non-empty-string $newName) : array<string, string>
Parameters
$folderIdentifier : non-empty-string
$newName : non-empty-string
Tags
throws
RuntimeException

if renaming the folder failed

Return values
array<string, string>

A map of old to new file identifiers of all affected files and folders

replaceFile()

Replaces the contents (and file-specific metadata) of a file with another file from the server's hard disk.

public replaceFile(non-empty-string $fileIdentifier, non-empty-string $localFilePath) : bool
Parameters
$fileIdentifier : non-empty-string
$localFilePath : non-empty-string
Return values
bool

sanitizeFileName()

Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' Trailing dots are removed

public sanitizeFileName(string $fileName[, non-empty-string $charset = 'utf-8' ]) : non-empty-string

Previously in \TYPO3\CMS\Core\Utility\File\BasicFileUtility::cleanFileName()

Parameters
$fileName : string

Input string, typically the body of a fileName

$charset : non-empty-string = 'utf-8'

Charset of the a fileName (defaults to utf-8)

Tags
todo:

at some point it is safe to drop the second argument $charset

Return values
non-empty-string

Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed

setFileContents()

Sets the contents of a file to the specified value.

public setFileContents(non-empty-string $fileIdentifier, string $contents) : int<0, max>
Parameters
$fileIdentifier : non-empty-string
$contents : string
Tags
throws
RuntimeException

if the operation failed

Return values
int<0, max>

The number of bytes written to the file

setStorageUid()

Sets the storage uid the driver belongs to

public setStorageUid(int $storageUid) : void
Parameters
$storageUid : int

streamFile()

Stream file using a PSR-7 Response object.

public streamFile(string $identifier, array<string|int, mixed> $properties) : ResponseInterface
Parameters
$identifier : string
$properties : array<string|int, mixed>
Return values
ResponseInterface

applyFilterMethodsToDirectoryItem()

Applies a set of filter methods to a file name to find out if it should be used or not.

protected applyFilterMethodsToDirectoryItem(array<string|int, mixed> $filterMethods, string $itemName, string $itemIdentifier, string $parentIdentifier) : bool

This is used by directory listings.

Parameters
$filterMethods : array<string|int, mixed>

The filter methods to use

$itemName : string
$itemIdentifier : string
$parentIdentifier : string
Return values
bool

calculateBasePath()

Calculates the absolute path to this driver's storage location

protected calculateBasePath(array<string|int, mixed> $configuration) : string
Parameters
$configuration : array<string|int, mixed>
Return values
string

canonicalizeAndCheckFileIdentifier()

Makes sure the Path given as parameter is valid.

protected canonicalizeAndCheckFileIdentifier(string $fileIdentifier) : string
Parameters
$fileIdentifier : string
Tags
phpstan-param

non-empty-string $fileIdentifier The file path (including the file name!)

phpstan-return

non-empty-string

Return values
string

canonicalizeAndCheckFilePath()

Makes sure the given path is valid.

protected canonicalizeAndCheckFilePath(string $filePath) : string
Parameters
$filePath : string
Tags
phpstan-param

non-empty-string $filePath The file path (including the file name!)

phpstan-return

non-empty-string

Return values
string

canonicalizeAndCheckFolderIdentifier()

Makes sure the Path given as parameter is valid.

protected canonicalizeAndCheckFolderIdentifier(string $folderIdentifier) : string
Parameters
$folderIdentifier : string
Tags
phpstan-param

non-empty-string $folderIdentifier The file path (including the file name!)

phpstan-return

non-empty-string

Return values
string

copyFileToTemporaryPath()

Copies a file to a temporary path and returns that path.

protected copyFileToTemporaryPath(string $fileIdentifier) : string
Parameters
$fileIdentifier : string
Return values
string

createIdentifierMap()

Creates a map of old and new file/folder identifiers after renaming or moving a folder. The old identifier is used as the key, the new one as the value.

protected createIdentifierMap(array<string|int, mixed> $filesAndFolders, string $sourceFolderIdentifier, string $targetFolderIdentifier) : array<non-empty-string, non-empty-string>
Parameters
$filesAndFolders : array<string|int, mixed>
$sourceFolderIdentifier : string
$targetFolderIdentifier : string
Return values
array<non-empty-string, non-empty-string>

determineBaseUrl()

Determines the base URL for this driver, from the configuration or the public path.

protected determineBaseUrl() : void

extractFileInformation()

Extracts information about a file from the filesystem.

protected extractFileInformation(string $filePath, string $containerPath[, array<string|int, mixed> $propertiesToExtract = [] ]) : array<string|int, mixed>
Parameters
$filePath : string

The absolute path to the file

$containerPath : string

The relative path to the file's container

$propertiesToExtract : array<string|int, mixed> = []

array of properties which should be returned, if empty all will be extracted

Return values
array<string|int, mixed>

getAbsoluteBasePath()

Returns the absolute path of the folder this driver operates on.

protected getAbsoluteBasePath() : string
Return values
string

getAbsolutePath()

Returns the absolute path of a file or folder.

protected getAbsolutePath(string $fileIdentifier) : string
Parameters
$fileIdentifier : string
Return values
string

getDirectoryItemList()

Generic wrapper for extracting a list of items from a path.

protected getDirectoryItemList(string $folderIdentifier, int $start, int $numberOfItems, array<string|int, mixed> $filterMethods[, bool $includeFiles = true ][, bool $includeDirs = true ][, bool $recursive = false ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, string>
Parameters
$folderIdentifier : string
$start : int

The position to start the listing; if not set, start from the beginning

$numberOfItems : int

The number of items to list; if set to zero, all items are returned

$filterMethods : array<string|int, mixed>

The filter methods used to filter the directory items

$includeFiles : bool = true
$includeDirs : bool = true
$recursive : bool = false
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, string>

folder identifiers (where key and value are identical, but int-like identifiers will get converted to int array keys)

getRecycleDirectory()

Get the path of the nearest recycler folder of a given path.

protected getRecycleDirectory(string $path) : string

Return an empty string if there is no recycler folder available in the base path.

Parameters
$path : string
Return values
string

getTemporaryPathForFile()

Returns a temporary path for a given file, including the file extension.

protected getTemporaryPathForFile(string $fileIdentifier) : string
Parameters
$fileIdentifier : string
Tags
phpstan-param

non-empty-string $fileIdentifier

phpstan-return

non-empty-string

Return values
string

isAllowedAbsolutePath()

Wrapper for `GeneralUtility::isAllowedAbsPath`, which implicitly invokes `GeneralUtility::validPathStr` (like in `parent::isPathValid`).

protected isAllowedAbsolutePath(string $path) : bool
Parameters
$path : string
Return values
bool

isPathValid()

Wrapper for \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr()

protected isPathValid(string $theFile) : bool
Parameters
$theFile : string
Return values
bool

TRUE if no '/', '..' or '' is in the $theFile

isValidFilename()

Checks a fileName for validity. This could be overridden in concrete drivers if they have different file naming rules.

protected isValidFilename(string $fileName) : bool
Parameters
$fileName : string
Return values
bool

recycleFileOrFolder()

Moves a file or folder to the given directory, renaming the source in the process if a file or folder of the same name already exists in the target path.

protected recycleFileOrFolder(string $filePath, string $recycleDirectory) : bool
Parameters
$filePath : string
$recycleDirectory : string
Return values
bool

retrieveFileAndFoldersInPath()

Returns a list with the names of all files and folders in a path, optionally recursive.

protected retrieveFileAndFoldersInPath(string $path[, bool $recursive = false ][, bool $includeFiles = true ][, bool $includeDirs = true ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, mixed>
Parameters
$path : string

The absolute path

$recursive : bool = false

If TRUE, recursively fetches files and folders

$includeFiles : bool = true
$includeDirs : bool = true
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, mixed>

sortDirectoryEntries()

Sort the directory entries by a certain key.

protected sortDirectoryEntries(array<string|int, mixed> $directoryEntries[, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, mixed>
Parameters
$directoryEntries : array<string|int, mixed>

Array of directory entry arrays from retrieveFileAndFoldersInPath()

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values
array<string|int, mixed>

Sorted entries. Content of the keys is undefined.


        
On this page

Search results