DriverInterface

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

Table of Contents

Methods

addFile()  : non-empty-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()  : non-empty-string
Copies a file *within* the current storage.
copyFolderWithinStorage()  : bool
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 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()  : void
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()  : Capabilities
Returns the capabilities of this driver.
getDefaultFolder()  : non-empty-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()  : non-empty-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<string, mixed>
Returns information about a file.
getFileInFolder()  : non-empty-string
Returns the identifier of a file inside the folder
getFilesInFolder()  : array<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 of a folder inside the 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()  : non-empty-string|null
Returns the public URL to a file.
getRootLevelFolder()  : non-empty-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()  : 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.
mergeConfigurationCapabilities()  : Capabilities
Merges the capabilities merged by the user at 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 a file with file in local file system.
sanitizeFileName()  : non-empty-string
Cleans a fileName from not allowed characters
setFileContents()  : int<0, max>
Sets the contents of a file to the specified value.
setStorageUid()  : void
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(non-empty-string $localFilePath, non-empty-string $targetFolderIdentifier[, string $newFileName = '' ][, bool $removeOriginal = true ]) : non-empty-string
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

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 : 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) : bool
Parameters
$sourceFolderIdentifier : non-empty-string
$targetFolderIdentifier : non-empty-string
$newFolderName : non-empty-string
Return values
bool

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 parent folder.

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

If no parent folder is given, a root level folder 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 Storage)!

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

deleteFolder()

Removes a folder in filesystem.

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. Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.

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

fileExists()

Checks if a file exists.

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

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(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, string> $propertiesToExtract = [] ]) : array<string, mixed>
Parameters
$fileIdentifier : non-empty-string
$propertiesToExtract : array<int, string> = []

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

Return values
array<string, mixed>

getFileInFolder()

Returns the identifier of a file inside the folder

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(non-empty-string $folderIdentifier[, int<0, max> $start = 0 ][, int<0, max> $numberOfItems = 0 ][, bool $recursive = false ][, array<int, callable> $filenameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array<int, string>
Parameters
$folderIdentifier : non-empty-string
$start : int<0, max> = 0
$numberOfItems : int<0, max> = 0
$recursive : bool = false
$filenameFilterCallbacks : array<int, callable> = []

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<int, string>

of FileIdentifiers

getFolderInfoByIdentifier()

Returns information about a folder.

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

getFolderInFolder()

Returns the identifier of a folder inside the 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

folder identifier

getFoldersInFolder()

Returns a list of folders inside the specified path

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

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(non-empty-string $fileIdentifier) : non-empty-string
Parameters
$fileIdentifier : 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 the public URL to a file.

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

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

Parameters
$identifier : non-empty-string
Return values
non-empty-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() : non-empty-string
Return values
non-empty-string

hasCapability()

Returns TRUE if this driver has the given capability.

public hasCapability(Capabilities::CAPABILITY_* $capability) : bool
Parameters
$capability : Capabilities::CAPABILITY_*
Return values
bool

hash()

Creates a hash for a file.

public hash(non-empty-string $fileIdentifier, non-empty-string $hashAlgorithm) : string
Parameters
$fileIdentifier : non-empty-string
$hashAlgorithm : non-empty-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(non-empty-string $identifier) : non-empty-string
Parameters
$identifier : 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.

public isWithin(non-empty-string $folderIdentifier, non-empty-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 : 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 merged by the user at 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

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

All files which are affected, map of old => 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
Return values
array<string, string>

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

replaceFile()

Replaces a file with file in local file system.

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

sanitizeFileName()

Cleans a fileName from not allowed characters

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

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

Return values
non-empty-string

the sanitized filename

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

        
On this page

Search results