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.

Table of Contents

Interfaces

Countable
LoggerAwareInterface

Properties

$fileCollectionRepository  : FileCollectionRepository
The file collection repository
$fileRepository  : FileRepository
The file repository
$files  : array
The files
$resourceFactory  : ResourceFactory
The resource factory

Methods

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

Properties

$files

The files

protected array $files = []

Methods

addFileReferences()

Add files from UIDs of a reference

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

Parameters

$fileReferenceUids : array = []

addFiles()

Add files

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

Parameters

$fileUids : array = []

addFilesFromFileCollection()

Add files to the collection from one single file collection

public addFilesFromFileCollection([int $fileCollectionUid = null ]) : mixed

Parameters

$fileCollectionUid : int = null

The file collections uid

addFilesFromFileCollections()

Add files to the collection from multiple file collections

public addFilesFromFileCollections([array $fileCollectionUids = [] ]) : mixed

Parameters

$fileCollectionUids : array = []

The file collections uids

addFilesFromFolder()

Add files to the collection from one single folder

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

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 ]) : mixed

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) : mixed

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 = '' ][, string $sortingOrder = 'ascending' ]) : mixed

Parameters

$sortingProperty : string = ''

The sorting property

$sortingOrder : string = 'ascending'

can be ascending or descending or "random"

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