FileCollector implements Countable, LoggerAwareInterface uses LoggerAwareTrait

Object to collect files from various sources during runtime.

Sources can be file references, file collections or folders.

Use in FILES Content Object or for a Fluid Data Processor.

Is not persisted, use only in FE.

Internal

this is an internal TYPO3 implementation and solely used for EXT:frontend and not part of TYPO3's Core API.

Tags
todo

The file collector is used for intermediate collection in scoped places. Therefore, the collector can't be shared. Evaluate if the collector can be build scope aware and made sharable again.

Attributes
#[Autoconfigure]
$public: true
$shared: false

Table of Contents

Interfaces

Countable
LoggerAwareInterface

Properties

$fileCollectionRepository  : FileCollectionRepository
$fileRepository  : FileRepository
$files  : array<string|int, FileInterface>
The collected File or FileReference objects
$resourceFactory  : ResourceFactory

Methods

__construct()  : mixed
addFileObject()  : void
Add a file object to the collection.
addFileObjects()  : void
Add multiple file objects to the collection.
addFileReferences()  : void
Add files from UIDs of a reference.
addFiles()  : void
Add files by UID
addFilesFromFileCollection()  : void
Add files to the collection from one single file collection.
addFilesFromFileCollections()  : void
Add files to the collection from multiple file collections.
addFilesFromFolder()  : void
Add files to the collection from one single folder.
addFilesFromFolders()  : void
Add files to the collection from multiple folders.
addFilesFromRelation()  : void
Add files to the collection from a relation.
count()  : int
getFiles()  : array<string|int, mixed>
Final getter method to fetch the accumulated data.
sort()  : void
Sort the file objects based on a property.
getFileReferences()  : array<string|int, mixed>
Gets file references for a given record field, also deal with translated elements, where file references could be attached.

Properties

Methods

addFileObjects()

Add multiple file objects to the collection.

public addFileObjects(array<string|int, FileInterface$files) : void
Parameters
$files : array<string|int, FileInterface>

The file objects

addFileReferences()

Add files from UIDs of a reference.

public addFileReferences([array<string|int, mixed> $fileReferenceUids = [] ]) : void
Parameters
$fileReferenceUids : array<string|int, mixed> = []

addFiles()

Add files by UID

public addFiles([array<string|int, mixed> $fileUids = [] ]) : void
Parameters
$fileUids : array<string|int, mixed> = []

addFilesFromFileCollection()

Add files to the collection from one single file collection.

public addFilesFromFileCollection(int $fileCollectionUid) : void
Parameters
$fileCollectionUid : int

addFilesFromFileCollections()

Add files to the collection from multiple file collections.

public addFilesFromFileCollections([array<string|int, mixed> $fileCollectionUids = [] ]) : void
Parameters
$fileCollectionUids : array<string|int, mixed> = []

addFilesFromFolder()

Add files to the collection from one single folder.

public addFilesFromFolder(string $folderIdentifier[, bool $recursive = false ]) : void
Parameters
$folderIdentifier : string

The folder identifier

$recursive : bool = false

Add files recursive from given folders

addFilesFromFolders()

Add files to the collection from multiple folders.

public addFilesFromFolders(array<string|int, mixed> $folderIdentifiers[, bool $recursive = false ]) : void
Parameters
$folderIdentifiers : array<string|int, mixed>

The folder identifiers

$recursive : bool = false

Add files recursive from given folders

addFilesFromRelation()

Add files to the collection from a relation.

public addFilesFromRelation(string $relationTable, string $relationField, array<string|int, mixed> $referenceRecord) : void
Parameters
$relationTable : string

The table of the relation (e.g. tt_content or pages)

$relationField : string

The field which holds the files (e.g. media or images)

$referenceRecord : array<string|int, mixed>

the record which is referencing the files

count()

public count() : int
Return values
int

getFiles()

Final getter method to fetch the accumulated data.

public getFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

sort()

Sort the file objects based on a property.

public sort([string $sortingProperty = '' ][, "ascending"|"descending"|"random" $sortingOrder = 'ascending' ]) : void
Parameters
$sortingProperty : string = ''

The sorting property

$sortingOrder : "ascending"|"descending"|"random" = 'ascending'

The sorting order

getFileReferences()

Gets file references for a given record field, also deal with translated elements, where file references could be attached.

protected getFileReferences(string $tableName, string $fieldName, array<string|int, mixed> $element) : array<string|int, mixed>
Parameters
$tableName : string

Name of the table

$fieldName : string

Name of the field

$element : array<string|int, mixed>

The parent element referencing to files

Return values
array<string|int, mixed>

        
On this page

Search results