FileExtensionFilter

class \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter

Utility methods for filtering filenames

Table of Contents

Properties

$allowedFileExtensions  : string[]|null
Allowed file extensions. If NULL, all extensions are allowed.
$disallowedFileExtensions  : string[]|null
Disallowed file extensions. If NULL, no extension is disallowed (i.e. all are allowed).

Methods

filter()  : array
filterFileList()  : bool|int
Entry method for use as filelist filter.
filterInlineChildren()  : array
Entry method for use as DataHandler "inline" field filter
getAllowedFileExtensions()  : array|null
getDisallowedFileExtensions()  : array|null
getFilteredFileExtensions()  : array
Compared the current allowed and disallowed lists and returns a filtered list either as allow or as disallow list. The "mode" is indicated by the array key, which is either "allowedFileExtensions" or "disallowedFileExtensions".
isAllowed()  : bool
Checks whether a file is allowed according to the criteria defined in the class variables ($this->allowedFileExtensions etc.)
setAllowedFileExtensions()  : void
Set allowed file extensions
setDisallowedFileExtensions()  : void
Set disallowed file extensions
convertToLowercaseArray()  : array|null
Converts mixed (string or array) input arguments into an array, NULL if empty.

Properties

$allowedFileExtensions

Allowed file extensions. If NULL, all extensions are allowed.

protected string[]|null $allowedFileExtensions = null

$disallowedFileExtensions

Disallowed file extensions. If NULL, no extension is disallowed (i.e. all are allowed).

protected string[]|null $disallowedFileExtensions = null

Methods

filterFileList()

Entry method for use as filelist filter.

public filterFileList(string $itemName, string $itemIdentifier, string $parentIdentifier, array $additionalInformation, DriverInterface $driver) : bool|int

We use -1 as the "don't include“ return value, for historic reasons, as call_user_func() used to return FALSE if calling the method failed.

Parameters

$itemName : string
$itemIdentifier : string
$parentIdentifier : string
$additionalInformation : array

Additional information about the inspected item

$driver : DriverInterface

Return values

bool|int —

-1 if the file should not be included in a listing

filterInlineChildren()

Entry method for use as DataHandler "inline" field filter

public filterInlineChildren(array $parameters, DataHandler|DatabaseRecordList $dataHandler) : array

Deprecated

Will be removed in TYPO3 v13. Use filterFileReferences() directly instead.

Parameters

$parameters : array
$dataHandler : DataHandler|DatabaseRecordList

Return values

array

getAllowedFileExtensions()

public getAllowedFileExtensions() : array|null

Return values

array|null

getDisallowedFileExtensions()

public getDisallowedFileExtensions() : array|null

Return values

array|null

getFilteredFileExtensions()

Compared the current allowed and disallowed lists and returns a filtered list either as allow or as disallow list. The "mode" is indicated by the array key, which is either "allowedFileExtensions" or "disallowedFileExtensions".

public getFilteredFileExtensions() : array

Return values

array

isAllowed()

Checks whether a file is allowed according to the criteria defined in the class variables ($this->allowedFileExtensions etc.)

public isAllowed(string $fileExtension) : bool

Parameters

$fileExtension : string

Return values

bool

setAllowedFileExtensions()

Set allowed file extensions

public setAllowedFileExtensions(mixed $allowedFileExtensions) : void

Parameters

$allowedFileExtensions : mixed

Comma-separated list or array, of allowed file extensions

setDisallowedFileExtensions()

Set disallowed file extensions

public setDisallowedFileExtensions(mixed $disallowedFileExtensions) : void

Parameters

$disallowedFileExtensions : mixed

Comma-separated list or array, of allowed file extensions

convertToLowercaseArray()

Converts mixed (string or array) input arguments into an array, NULL if empty.

protected convertToLowercaseArray(mixed $inputArgument) : array|null

All array values will be converted to lower case.

Parameters

$inputArgument : mixed

Return values

array|null
On this page