DriverInterface

interface \TYPO3\CMS\Core\Resource\Driver\DriverInterface

An interface Drivers have to implement to fulfil the needs of the FAL API.

Table of Contents

Methods

addFile()  : string
Adds a file from the local server hard disk to a given path in TYPO3s virtual file system. This assumes that the local file exists, so no further check is done here! After a successful operation the original file must not exist anymore.
copyFileWithinStorage()  : string
Copies a file *within* the current storage.
copyFolderWithinStorage()  : bool
Folder equivalent to copyFileWithinStorage().
countFilesInFolder()  : int
Returns the number of files inside the specified path
countFoldersInFolder()  : int
Returns the number of folders inside the specified path
createFile()  : string
Creates a new (empty) file and returns the identifier.
createFolder()  : string
Creates a folder, within a 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 Storage)!
deleteFolder()  : bool
Removes a folder in filesystem.
dumpFileContents()  : mixed
Directly output the contents of the file to the output buffer. Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.
fileExists()  : bool
Checks if a file exists.
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()  : int
Returns the capabilities of this driver.
getDefaultFolder()  : string
Returns the identifier of the default folder 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()  : string
Returns a path to a local copy of a file for processing it. When changing the file, you have to take care of replacing the current version yourself!
getFileInfoByIdentifier()  : array
Returns information about a file.
getFileInFolder()  : string
Returns the identifier of a file inside the folder
getFilesInFolder()  : array
Returns a list of files inside the specified path
getFolderInfoByIdentifier()  : array
Returns information about a file.
getFolderInFolder()  : string
Returns the identifier of a folder inside the folder
getFoldersInFolder()  : array<string|int, string>
Returns a list of folders inside the specified path
getParentFolderIdentifierOfIdentifier()  : string
Returns the identifier of the folder the file resides in
getPermissions()  : array
Returns the permissions of a file/folder as an array (keys r, w) of boolean flags
getPublicUrl()  : string|null
Returns the public URL to a file.
getRootLevelFolder()  : string
Returns the identifier of the root level folder of the storage.
hasCapability()  : bool
Returns TRUE if this driver has the given capability.
hash()  : string
Creates a hash for a file.
hashIdentifier()  : string
Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.
initialize()  : mixed
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.
mergeConfigurationCapabilities()  : int
Merges the capabilities merged by the user at the storage configuration into the actual capabilities of the driver and returns the result.
moveFileWithinStorage()  : string
Moves a file *within* the current storage.
moveFolderWithinStorage()  : array
Folder equivalent to moveFileWithinStorage().
processConfiguration()  : mixed
Processes the configuration for this driver.
renameFile()  : string
Renames a file in this storage.
renameFolder()  : array
Renames a folder in this storage.
replaceFile()  : bool
Replaces a file with file in local file system.
sanitizeFileName()  : string
Cleans a fileName from not allowed characters
setFileContents()  : int
Sets the contents of a file to the specified value.
setStorageUid()  : mixed
Sets the storage uid the driver belongs to

Methods

addFile()

Adds a file from the local server hard disk to a given path in TYPO3s virtual file system. This assumes that the local file exists, so no further check is done here! After a successful operation the original file must not exist anymore.

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

Parameters

$localFilePath : string

within public web path

$targetFolderIdentifier : 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

string —

the identifier of the new file

copyFileWithinStorage()

Copies a file *within* the current storage.

public copyFileWithinStorage(string $fileIdentifier, string $targetFolderIdentifier, string $fileName) : string

Note that this is only about an inner storage copy action, where a file is just copied to another folder in the same storage.

Parameters

$fileIdentifier : string
$targetFolderIdentifier : string
$fileName : string

Return values

string —

the Identifier of the new file

copyFolderWithinStorage()

Folder equivalent to copyFileWithinStorage().

public copyFolderWithinStorage(string $sourceFolderIdentifier, string $targetFolderIdentifier, string $newFolderName) : bool

Parameters

$sourceFolderIdentifier : string
$targetFolderIdentifier : string
$newFolderName : string

Return values

bool

countFilesInFolder()

Returns the number of files inside the specified path

public countFilesInFolder(string $folderIdentifier[, bool $recursive = false ][, array $filenameFilterCallbacks = [] ]) : int

Parameters

$folderIdentifier : string
$recursive : bool = false
$filenameFilterCallbacks : array = []

callbacks for filtering the items

Return values

int —

Number of files in folder

countFoldersInFolder()

Returns the number of folders inside the specified path

public countFoldersInFolder(string $folderIdentifier[, bool $recursive = false ][, array $folderNameFilterCallbacks = [] ]) : int

Parameters

$folderIdentifier : string
$recursive : bool = false
$folderNameFilterCallbacks : array = []

callbacks for filtering the items

Return values

int —

Number of folders in folder

createFile()

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

public createFile(string $fileName, string $parentFolderIdentifier) : string

Parameters

$fileName : string
$parentFolderIdentifier : string

Return values

string

createFolder()

Creates a folder, within a parent folder.

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

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

Parameters

$newFolderName : string
$parentFolderIdentifier : string = ''
$recursive : bool = false

Return values

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 Storage)!

public deleteFile(string $fileIdentifier) : bool

Parameters

$fileIdentifier : string

Return values

bool —

TRUE if deleting the file succeeded

deleteFolder()

Removes a folder in filesystem.

public deleteFolder(string $folderIdentifier[, bool $deleteRecursively = false ]) : bool

Parameters

$folderIdentifier : string
$deleteRecursively : bool = false

Return values

bool

dumpFileContents()

Directly output the contents of the file to the output buffer. Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.

public dumpFileContents(string $identifier) : mixed

Parameters

$identifier : string

fileExists()

Checks if a file exists.

public fileExists(string $fileIdentifier) : bool

Parameters

$fileIdentifier : string

Return values

bool

fileExistsInFolder()

Checks if a file inside a folder exists

public fileExistsInFolder(string $fileName, string $folderIdentifier) : bool

Parameters

$fileName : string
$folderIdentifier : string

Return values

bool

folderExists()

Checks if a folder exists.

public folderExists(string $folderIdentifier) : bool

Parameters

$folderIdentifier : string

Return values

bool

folderExistsInFolder()

Checks if a folder inside a folder exists.

public folderExistsInFolder(string $folderName, string $folderIdentifier) : bool

Parameters

$folderName : string
$folderIdentifier : string

Return values

bool

getCapabilities()

Returns the capabilities of this driver.

public getCapabilities() : int

Tags

see
ResourceStorageInterface::CAPABILITY_

constants

Return values

int

getDefaultFolder()

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

public getDefaultFolder() : string

Return values

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(string $fileIdentifier) : string

Parameters

$fileIdentifier : string

Return values

string —

The file contents

getFileForLocalProcessing()

Returns a path to a local copy of a file for processing it. When changing the file, you have to take care of replacing the current version yourself!

public getFileForLocalProcessing(string $fileIdentifier[, bool $writable = true ]) : string

Parameters

$fileIdentifier : 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

string —

The path to the file on the local disk

getFileInfoByIdentifier()

Returns information about a file.

public getFileInfoByIdentifier(string $fileIdentifier[, array $propertiesToExtract = [] ]) : array

Parameters

$fileIdentifier : string
$propertiesToExtract : array = []

Array of properties which are be extracted If empty all will be extracted

Return values

array

getFileInFolder()

Returns the identifier of a file inside the folder

public getFileInFolder(string $fileName, string $folderIdentifier) : string

Parameters

$fileName : string
$folderIdentifier : string

Return values

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 $filenameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array

Parameters

$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$filenameFilterCallbacks : array = []

callbacks 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 —

of FileIdentifiers

getFolderInfoByIdentifier()

Returns information about a file.

public getFolderInfoByIdentifier(string $folderIdentifier) : array

Parameters

$folderIdentifier : string

Return values

array

getFolderInFolder()

Returns the identifier of a folder inside the folder

public getFolderInFolder(string $folderName, string $folderIdentifier) : string

Parameters

$folderName : string

The name of the target folder

$folderIdentifier : string

Return values

string —

folder identifier

getFoldersInFolder()

Returns a list of folders inside the specified path

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

Parameters

$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$folderNameFilterCallbacks : array = []

callbacks 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) : string

Parameters

$fileIdentifier : string

Return values

string

getPermissions()

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

public getPermissions(string $identifier) : array

Parameters

$identifier : string

Return values

array

getPublicUrl()

Returns the public URL to a file.

public getPublicUrl(string $identifier) : string|null

Either fully qualified URL or relative to public web path (rawurlencoded).

Parameters

$identifier : string

Return values

string|null —

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

getRootLevelFolder()

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

public getRootLevelFolder() : string

Return values

string

hasCapability()

Returns TRUE if this driver has the given capability.

public hasCapability(int $capability) : bool

Parameters

$capability : int

A capability, as defined in a CAPABILITY_* constant

Return values

bool

hash()

Creates a 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) : string

Parameters

$identifier : string

Return values

string

initialize()

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

public initialize() : mixed

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(string $folderIdentifier) : bool

Parameters

$folderIdentifier : 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.

public isWithin(string $folderIdentifier, string $identifier) : bool

This can e.g. be used to check for web-mounts.

Hint: this also needs to return TRUE if the given identifier matches the container identifier to allow access to the root folder of a filemount.

Parameters

$folderIdentifier : string
$identifier : string

identifier to be checked against $folderIdentifier

Return values

bool —

TRUE if $content is within or matches $folderIdentifier

mergeConfigurationCapabilities()

Merges the capabilities merged by the user at the storage configuration into the actual capabilities of the driver and returns the result.

public mergeConfigurationCapabilities(int $capabilities) : int

Parameters

$capabilities : int

Return values

int

moveFileWithinStorage()

Moves a file *within* the current storage.

public moveFileWithinStorage(string $fileIdentifier, string $targetFolderIdentifier, string $newFileName) : string

Note that this is only about an inner-storage move action, where a file is just moved to another folder in the same storage.

Parameters

$fileIdentifier : string
$targetFolderIdentifier : string
$newFileName : string

Return values

string

moveFolderWithinStorage()

Folder equivalent to moveFileWithinStorage().

public moveFolderWithinStorage(string $sourceFolderIdentifier, string $targetFolderIdentifier, string $newFolderName) : array

Parameters

$sourceFolderIdentifier : string
$targetFolderIdentifier : string
$newFolderName : string

Return values

array —

All files which are affected, map of old => new file identifiers

processConfiguration()

Processes the configuration for this driver.

public processConfiguration() : mixed

renameFile()

Renames a file in this storage.

public renameFile(string $fileIdentifier, string $newName) : string

Parameters

$fileIdentifier : string
$newName : string

The target path (including the file name!)

Return values

string —

The identifier of the file after renaming

renameFolder()

Renames a folder in this storage.

public renameFolder(string $folderIdentifier, string $newName) : array

Parameters

$folderIdentifier : string
$newName : string

Return values

array —

A map of old to new file identifiers of all affected resources

replaceFile()

Replaces a file with file in local file system.

public replaceFile(string $fileIdentifier, string $localFilePath) : bool

Parameters

$fileIdentifier : string
$localFilePath : string

Return values

bool —

TRUE if the operation succeeded

sanitizeFileName()

Cleans a fileName from not allowed characters

public sanitizeFileName(string $fileName[, string $charset = '' ]) : string

Parameters

$fileName : string
$charset : string = ''

Charset of the a fileName (defaults to current charset; depending on context)

Return values

string —

the cleaned filename

setFileContents()

Sets the contents of a file to the specified value.

public setFileContents(string $fileIdentifier, string $contents) : int

Parameters

$fileIdentifier : string
$contents : string

Return values

int —

The number of bytes written to the file

setStorageUid()

Sets the storage uid the driver belongs to

public setStorageUid(int $storageUid) : mixed

Parameters

$storageUid : int
On this page