Feature: #87610 - New FAL API to search for files including their meta data

See forge#87610


A new API is introduced to search for files in a storage or folder, which includes matches in meta data of those files. The given search term is looked for in all search fields defined in TCA of sys_file and sys_file_metadata tables.

A new driver capability \TYPO3\CMS\Core\Resource\ResourceStorageInterface::CAPABILITY_HIERARCHICAL_IDENTIFIERS is introduced to allow implementing an optimized search with good performance. Drivers can optionally add this capability in case the identifiers that are constructed by the driver include the directory structure. Adding this capability to drivers can provide a big performance boost when it comes to recursive search (which is default in the file list and file browser UI).


This change is fully backwards compatible. Custom driver implementations will continue to work like before, but they won't benefit from the performance gain unless the new capability is added.

Searching for files in a folder works like this:

$searchDemand = FileSearchDemand::createForSearchTerm($searchWord)->withRecursive();
$files = $folder->searchFiles($searchDemand);

Searching for files in a complete storage works like this:

$searchDemand = FileSearchDemand::createForSearchTerm($searchWord)->withRecursive();
$files = $storage->searchFiles($searchDemand);

It is possible to further limit the result set, by adding additional restrictions to TYPO3\CMS\Core\Resource\Folder\FileSearchDemand. Please note, that TYPO3\CMS\Core\Resource\Folder\FileSearchDemand is an immutable value object, but allows chaining methods for ease of use:

$searchDemand = FileSearchDemand::createForSearchTerm($this->searchWord)
$files = $storage->searchFiles($searchDemand);