Folder implements FolderInterface

A folder that groups files in a storage. This may be a folder on the local disk, a bucket in Amazon S3 or a user or a tag in Flickr.

This object is not persisted in TYPO3 locally, but created on the fly by storage drivers for the folders they "offer".

Some folders serve as a physical container for files (e.g. folders on the local disk, S3 buckets or Flickr users). Other folders just group files by a certain criterion, e.g. a tag. The way this is implemented depends on the storage driver.

Table of Contents

Interfaces

FolderInterface
Interface for folders

Constants

FILTER_MODE_NO_FILTERS  = 0
Modes for filter usage in getFiles()/getFolders()
FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS  = 1
FILTER_MODE_USE_OWN_FILTERS  = 3
FILTER_MODE_USE_STORAGE_FILTERS  = 2

Properties

$fileAndFolderNameFilters  : array<string|int, callable>
The filters this folder should use for a filelist.
$identifier  : string
The identifier of this folder to identify it on the storage.
$name  : string
The name of this folder
$storage  : ResourceStorage
The storage this folder belongs to.

Methods

__construct()  : mixed
Initialization of the folder
addFile()  : File
Adds a file from the local server disk. If the file already exists and overwriting is disabled,
addUploadedFile()  : File
Adds an uploaded file into the Storage.
checkActionPermission()  : bool
Check if a file operation (= action) is allowed on this folder
copyTo()  : Folder
Copies folder to a target folder
createFile()  : File
Creates a new blank file
createFolder()  : Folder
Creates a new folder
delete()  : bool
Deletes this folder from its storage. This also means that this object becomes useless.
getCombinedIdentifier()  : string
Returns a combined identifier of this folder, i.e. the storage UID and the folder identifier separated by a colon ":".
getCreationTime()  : int
Returns the creation time of the file as Unix timestamp
getFile()  : File|ProcessedFile|null
Fetches a file from a folder, must be a direct descendant of a folder.
getFileCount()  : int
Returns amount of all files within this folder, optionally filtered by the given pattern
getFiles()  : array<string|int, File>
Returns a list of files in this folder, optionally filtered. There are several filter modes available, see the FILTER_MODE_* constants for more information.
getHashedIdentifier()  : string
Get hashed identifier
getIdentifier()  : string
Returns the path of this folder inside the storage. It depends on the type of storage whether this is a real path or just some unique identifier.
getModificationTime()  : int
Returns the modification time of the file as Unix timestamp
getName()  : string
Returns the name of this folder.
getParentFolder()  : FolderInterface
Returns the parent folder.
getPublicUrl()  : string|null
Returns a publicly accessible URL for this folder
getReadablePath()  : string
Returns the full path of this folder, from the root.
getRole()  : string
Returns the role of this folder (if any). See FolderInterface::ROLE_* constants for possible values.
getStorage()  : ResourceStorage
Returns the storage this folder belongs to.
getSubfolder()  : Folder
Returns the object for a subfolder of the current folder, if it exists.
getSubfolders()  : array<string|int, Folder>
hasFile()  : bool
Checks if a file exists in this folder
hasFolder()  : bool
Checks if a folder exists in this folder.
moveTo()  : Folder
Moves folder to a target folder
rename()  : Folder
Renames this folder.
searchFiles()  : FileSearchResultInterface
Returns a file search result based on the given demand.
setFileAndFolderNameFilters()  : mixed
Sets the filters to use when listing files. These are only used if the filter mode is one of FILTER_MODE_USE_OWN_FILTERS and FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
setName()  : mixed
Sets a new name of the folder currently this does not trigger the "renaming process" as the name is more seen as a label
updateProperties()  : mixed
Updates the properties of this folder, e.g. after re-indexing or moving it.
prepareFiltersInStorage()  : array<string|int, mixed>
Prepares the filters in this folder's storage according to a set filter mode.
restoreBackedUpFiltersInStorage()  : mixed
Restores the filters of a storage.

Constants

FILTER_MODE_NO_FILTERS

Modes for filter usage in getFiles()/getFolders()

public mixed FILTER_MODE_NO_FILTERS = 0

FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

public mixed FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS = 1

FILTER_MODE_USE_OWN_FILTERS

public mixed FILTER_MODE_USE_OWN_FILTERS = 3

FILTER_MODE_USE_STORAGE_FILTERS

public mixed FILTER_MODE_USE_STORAGE_FILTERS = 2

Properties

$fileAndFolderNameFilters

The filters this folder should use for a filelist.

protected array<string|int, callable> $fileAndFolderNameFilters = []

$identifier

The identifier of this folder to identify it on the storage.

protected string $identifier

On some drivers, this is the path to the folder, but drivers could also just provide any other unique identifier for this folder on the specific storage.

$name

The name of this folder

protected string $name

Methods

__construct()

Initialization of the folder

public __construct(ResourceStorage $storage, string $identifier, string $name) : mixed
Parameters
$storage : ResourceStorage
$identifier : string
$name : string

addFile()

Adds a file from the local server disk. If the file already exists and overwriting is disabled,

public addFile(string $localFilePath[, string $fileName = null ][, string $conflictMode = DuplicationBehavior::CANCEL ]) : File
Parameters
$localFilePath : string
$fileName : string = null
$conflictMode : string = DuplicationBehavior::CANCEL

a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration

Return values
File

The file object

addUploadedFile()

Adds an uploaded file into the Storage.

public addUploadedFile(array<string|int, mixed> $uploadedFileData[, string $conflictMode = DuplicationBehavior::CANCEL ]) : File
Parameters
$uploadedFileData : array<string|int, mixed>

contains information about the uploaded file given by $_FILES['file1']

$conflictMode : string = DuplicationBehavior::CANCEL

a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration

Return values
File

The file object

checkActionPermission()

Check if a file operation (= action) is allowed on this folder

public checkActionPermission(string $action) : bool
Parameters
$action : string

Action that can be read, write or delete

Return values
bool

copyTo()

Copies folder to a target folder

public copyTo(Folder $targetFolder[, string $targetFolderName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : Folder
Parameters
$targetFolder : Folder

Target folder to copy to.

$targetFolderName : string = null

an optional destination fileName

$conflictMode : string = DuplicationBehavior::RENAME

a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration

Return values
Folder

New (copied) folder object.

createFile()

Creates a new blank file

public createFile(string $fileName) : File
Parameters
$fileName : string
Return values
File

The new file object

createFolder()

Creates a new folder

public createFolder(string $folderName) : Folder
Parameters
$folderName : string
Return values
Folder

The new folder object

delete()

Deletes this folder from its storage. This also means that this object becomes useless.

public delete([bool $deleteRecursively = true ]) : bool
Parameters
$deleteRecursively : bool = true
Return values
bool

TRUE if deletion succeeded

getCombinedIdentifier()

Returns a combined identifier of this folder, i.e. the storage UID and the folder identifier separated by a colon ":".

public getCombinedIdentifier() : string
Return values
string

Combined storage and folder identifier, e.g. StorageUID:folder/path/

getCreationTime()

Returns the creation time of the file as Unix timestamp

public getCreationTime() : int
Return values
int

getFileCount()

Returns amount of all files within this folder, optionally filtered by the given pattern

public getFileCount([array<string|int, mixed> $filterMethods = [] ][, bool $recursive = false ]) : int
Parameters
$filterMethods : array<string|int, mixed> = []
$recursive : bool = false
Tags
throws
InsufficientFolderAccessPermissionsException
Return values
int

getFiles()

Returns a list of files in this folder, optionally filtered. There are several filter modes available, see the FILTER_MODE_* constants for more information.

public getFiles([int $start = 0 ][, int $numberOfItems = 0 ][, int $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS ][, bool $recursive = false ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, File>

For performance reasons the returned items can also be limited to a given range

Parameters
$start : int = 0

The item to start at

$numberOfItems : int = 0

The number of items to return

$filterMode : int = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

The filter mode to use for the filelist.

$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, File>

getHashedIdentifier()

Get hashed identifier

public getHashedIdentifier() : string
Return values
string

getIdentifier()

Returns the path of this folder inside the storage. It depends on the type of storage whether this is a real path or just some unique identifier.

public getIdentifier() : string
Return values
string

getModificationTime()

Returns the modification time of the file as Unix timestamp

public getModificationTime() : int
Return values
int

getName()

Returns the name of this folder.

public getName() : string
Return values
string

getPublicUrl()

Returns a publicly accessible URL for this folder

public getPublicUrl([bool $relativeToCurrentScript = false ]) : string|null

WARNING: Access to the folder may be restricted by further means, e.g. some web-based authentication. You have to take care of this yourself.

Parameters
$relativeToCurrentScript : bool = false

Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver). Deprecated since TYPO3 v11, will be removed in TYPO3 v12.0

Return values
string|null

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

getReadablePath()

Returns the full path of this folder, from the root.

public getReadablePath([string $rootId = null ]) : string
Parameters
$rootId : string = null

ID of the root folder, NULL to auto-detect

Return values
string

getRole()

Returns the role of this folder (if any). See FolderInterface::ROLE_* constants for possible values.

public getRole() : string
Return values
string

getSubfolder()

Returns the object for a subfolder of the current folder, if it exists.

public getSubfolder(string $name) : Folder
Parameters
$name : string

Name of the subfolder

Tags
throws
InvalidArgumentException
Return values
Folder

getSubfolders()

public getSubfolders([int $start = 0 ][, int $numberOfItems = 0 ][, int $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS ][, bool $recursive = false ]) : array<string|int, Folder>
Parameters
$start : int = 0

The item to start at

$numberOfItems : int = 0

The number of items to return

$filterMode : int = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

The filter mode to use for the filelist.

$recursive : bool = false
Return values
array<string|int, Folder>

hasFile()

Checks if a file exists in this folder

public hasFile(string $name) : bool
Parameters
$name : string
Return values
bool

hasFolder()

Checks if a folder exists in this folder.

public hasFolder(string $name) : bool
Parameters
$name : string
Return values
bool

moveTo()

Moves folder to a target folder

public moveTo(Folder $targetFolder[, string $targetFolderName = null ][, string $conflictMode = DuplicationBehavior::RENAME ]) : Folder
Parameters
$targetFolder : Folder

Target folder to move to.

$targetFolderName : string = null

an optional destination fileName

$conflictMode : string = DuplicationBehavior::RENAME

a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration

Return values
Folder

New (copied) folder object.

rename()

Renames this folder.

public rename(string $newName) : Folder
Parameters
$newName : string
Return values
Folder

searchFiles()

Returns a file search result based on the given demand.

public searchFiles(FileSearchDemand $searchDemand[, int $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS ]) : FileSearchResultInterface

The result also includes matches in meta data fields that are defined in TCA.

Parameters
$searchDemand : FileSearchDemand
$filterMode : int = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

The filter mode to use for the found files

Return values
FileSearchResultInterface

setFileAndFolderNameFilters()

Sets the filters to use when listing files. These are only used if the filter mode is one of FILTER_MODE_USE_OWN_FILTERS and FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS

public setFileAndFolderNameFilters(array<string|int, mixed> $filters) : mixed
Parameters
$filters : array<string|int, mixed>

setName()

Sets a new name of the folder currently this does not trigger the "renaming process" as the name is more seen as a label

public setName(string $name) : mixed
Parameters
$name : string

The new name

updateProperties()

Updates the properties of this folder, e.g. after re-indexing or moving it.

public updateProperties(array<string|int, mixed> $properties) : mixed

NOTE: This method should not be called from outside the File Abstraction Layer (FAL)!

Parameters
$properties : array<string|int, mixed>
Internal

prepareFiltersInStorage()

Prepares the filters in this folder's storage according to a set filter mode.

protected prepareFiltersInStorage(int $filterMode) : array<string|int, mixed>
Parameters
$filterMode : int

The filter mode to use; one of the FILTER_MODE_* constants

Return values
array<string|int, mixed>

The backed up filters as an array (NULL if filters were not backed up) and whether to use filters or not (bool)

restoreBackedUpFiltersInStorage()

Restores the filters of a storage.

protected restoreBackedUpFiltersInStorage(array<string|int, mixed> $backedUpFilters) : mixed
Parameters
$backedUpFilters : array<string|int, mixed>

The filters to restore; might be NULL if no filters have been backed up, in which case this method does nothing.

Tags
see
prepareFiltersInStorage()

        
On this page

Search results