‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\Resource\FileCollector Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\Resource\FileCollector:

Public Member Functions

 __construct (protected readonly ResourceFactory $resourceFactory, protected readonly FileCollectionRepository $fileCollectionRepository, protected readonly FileRepository $fileRepository,)
 
 addFiles (array $fileUids=[])
 
 addFilesFromRelation (string $relationTable, string $relationField, array $referenceRecord)
 
 addFileReferences (array $fileReferenceUids=[])
 
 addFilesFromFileCollections (array $fileCollectionUids=[])
 
 addFilesFromFileCollection (int $fileCollectionUid)
 
 addFilesFromFolders (array $folderIdentifiers, bool $recursive=false)
 
 addFilesFromFolder (string $folderIdentifier, bool $recursive=false)
 
 sort (string $sortingProperty='', string $sortingOrder='ascending')
 
 addFileObject (FileInterface $file)
 
 addFileObjects (array $files)
 
 getFiles ()
 
 count ()
 

Protected Member Functions

 getFileReferences (string $tableName, string $fieldName, array $element)
 

Protected Attributes

array $files = []
 

Detailed Description

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.

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

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.

Definition at line 46 of file FileCollector.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Frontend\Resource\FileCollector::__construct ( protected readonly ResourceFactory  $resourceFactory,
protected readonly FileCollectionRepository  $fileCollectionRepository,
protected readonly FileRepository  $fileRepository 
)

Definition at line 57 of file FileCollector.php.

Member Function Documentation

◆ addFileObject()

TYPO3\CMS\Frontend\Resource\FileCollector::addFileObject ( FileInterface  $file)

Add a file object to the collection.

Definition at line 226 of file FileCollector.php.

Referenced by TYPO3\CMS\Frontend\Resource\FileCollector\addFileReferences(), and TYPO3\CMS\Frontend\Resource\FileCollector\addFiles().

◆ addFileObjects()

TYPO3\CMS\Frontend\Resource\FileCollector::addFileObjects ( array  $files)

◆ addFileReferences()

TYPO3\CMS\Frontend\Resource\FileCollector::addFileReferences ( array  $fileReferenceUids = [])

Add files from UIDs of a reference.

Definition at line 99 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\addFileObject().

◆ addFiles()

TYPO3\CMS\Frontend\Resource\FileCollector::addFiles ( array  $fileUids = [])

Add files by UID

Definition at line 66 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\addFileObject().

◆ addFilesFromFileCollection()

TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromFileCollection ( int  $fileCollectionUid)

◆ addFilesFromFileCollections()

TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromFileCollections ( array  $fileCollectionUids = [])

Add files to the collection from multiple file collections.

Definition at line 113 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\addFilesFromFileCollection().

◆ addFilesFromFolder()

TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromFolder ( string  $folderIdentifier,
bool  $recursive = false 
)

Add files to the collection from one single folder.

Parameters
string$folderIdentifier‪The folder identifier
bool$recursive‪Add files recursive from given folders

Definition at line 163 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\$files, TYPO3\CMS\Frontend\Resource\FileCollector\addFileObjects(), and TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS.

Referenced by TYPO3\CMS\Frontend\Resource\FileCollector\addFilesFromFolders().

◆ addFilesFromFolders()

TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromFolders ( array  $folderIdentifiers,
bool  $recursive = false 
)

Add files to the collection from multiple folders.

Parameters
array$folderIdentifiers‪The folder identifiers
bool$recursive‪Add files recursive from given folders

Definition at line 150 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\addFilesFromFolder().

◆ addFilesFromRelation()

TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromRelation ( string  $relationTable,
string  $relationField,
array  $referenceRecord 
)

Add files to the collection from a relation.

Parameters
string$relationTable‪The table of the relation (e.g. tt_content or pages)
string$relationField‪The field which holds the files (e.g. media or images)
array$referenceRecord‪the record which is referencing the files

Definition at line 88 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\addFileObjects(), and TYPO3\CMS\Frontend\Resource\FileCollector\getFileReferences().

Referenced by TYPO3\CMS\Frontend\ContentObject\FilesContentObject\addFileReferences().

◆ count()

TYPO3\CMS\Frontend\Resource\FileCollector::count ( )

Definition at line 249 of file FileCollector.php.

Referenced by TYPO3\CMS\Frontend\Resource\FileCollector\sort().

◆ getFileReferences()

TYPO3\CMS\Frontend\Resource\FileCollector::getFileReferences ( string  $tableName,
string  $fieldName,
array  $element 
)
protected

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

Parameters
string$tableName‪Name of the table
string$fieldName‪Name of the field
array$element‪The parent element referencing to files

We just catch the exception here Reasoning: There is nothing an editor or even admin could do

The storage does not exist anymore Log the exception message for admins as they maybe can restore the storage

Definition at line 262 of file FileCollector.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\Resource\FileCollector\addFilesFromRelation().

◆ getFiles()

TYPO3\CMS\Frontend\Resource\FileCollector::getFiles ( )

Final getter method to fetch the accumulated data.

Definition at line 244 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\$files.

◆ sort()

TYPO3\CMS\Frontend\Resource\FileCollector::sort ( string  $sortingProperty = '',
string  $sortingOrder = 'ascending' 
)

Sort the file objects based on a property.

Parameters
string$sortingProperty‪The sorting property
'ascending'|'descending'|'random'‪$sortingOrder The sorting order

Definition at line 194 of file FileCollector.php.

References TYPO3\CMS\Frontend\Resource\FileCollector\count(), and TYPO3\CMS\Core\Resource\FileInterface\hasProperty().

Member Data Documentation

◆ $files