FileCollector
class \
- 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
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
$fileCollectionRepository read-only
protected
FileCollectionRepository
$fileCollectionRepository
$fileRepository read-only
protected
FileRepository
$fileRepository
$files
The collected File or FileReference objects
protected
FileInterface[]
$files
= []
$resourceFactory read-only
protected
ResourceFactory
$resourceFactory
Methods
__construct()
public
__construct(ResourceFactory $resourceFactory, FileCollectionRepository $fileCollectionRepository, FileRepository $fileRepository) : mixed
Parameters
- $resourceFactory : ResourceFactory
- $fileCollectionRepository : FileCollectionRepository
- $fileRepository : FileRepository
addFileObject()
Add a file object to the collection.
public
addFileObject(FileInterface $file) : void
Parameters
- $file : FileInterface
addFileObjects()
Add multiple file objects to the collection.
public
addFileObjects(FileInterface[] $files) : void
Parameters
- $files : FileInterface[]
-
The file objects
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
intgetFiles()
Final getter method to fetch the accumulated data.
public
getFiles() : array
Return values
arraysort()
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