FileCollector

class \TYPO3\CMS\Frontend\Resource\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.

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  : 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
Final getter method to fetch the accumulated data.
sort()  : void
Sort the file objects based on a property.
getFileReferences()  : array
Gets file references for a given record field, also deal with translated elements, where file references could be attached.

Properties

Methods

addFileReferences()

Add files from UIDs of a reference.

public addFileReferences([array $fileReferenceUids = [] ]) : void

Parameters

$fileReferenceUids : array = []

addFiles()

Add files by UID

public addFiles([array $fileUids = [] ]) : void

Parameters

$fileUids : array = []

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 $fileCollectionUids = [] ]) : void

Parameters

$fileCollectionUids : array = []

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 $folderIdentifiers[, bool $recursive = false ]) : void

Parameters

$folderIdentifiers : array

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

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

Return values

array

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 $element) : array

Parameters

$tableName : string

Name of the table

$fieldName : string

Name of the field

$element : array

The parent element referencing to files

Return values

array
On this page