‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Resource\FileRepository Class Reference

Public Member Functions

 __construct (protected readonly ResourceFactory $factory)
 
 findByUid (int $uid)
 
FileReference[] findByRelation (string $tableName, string $fieldName, int $uid, int $workspaceId=null)
 

Protected Member Functions

 createDomainObject (array $databaseRow)
 
FileReference[] reapplySorting (array $itemList)
 
 isFrontend ()
 

Detailed Description

Repository for accessing file objects. It also serves as the public API for the indexing part of files in general.

It is however recommended to use the ResourceFactory instead of this class, as it is more flexible.

Definition at line 37 of file FileRepository.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\FileRepository::__construct ( protected readonly ResourceFactory  $factory)

Definition at line 39 of file FileRepository.php.

Member Function Documentation

◆ createDomainObject()

TYPO3\CMS\Core\Resource\FileRepository::createDomainObject ( array  $databaseRow)
protected

Creates an object managed by this repository.

Definition at line 69 of file FileRepository.php.

Referenced by TYPO3\CMS\Core\Resource\FileRepository\findByUid().

◆ findByRelation()

FileReference [] TYPO3\CMS\Core\Resource\FileRepository::findByRelation ( string  $tableName,
string  $fieldName,
int  $uid,
int  $workspaceId = null 
)

Find FileReference objects by relation to other records

Parameters
string$tableName‪Table name of the related record
string$fieldName‪Field name of the related record
int$uid‪The UID of the related record (needs to be the localized uid, as translated IRRE elements relate to them)
?int‪$workspaceId
Returns
FileReference[] An array of file references, empty if no objects found

Definition at line 83 of file FileRepository.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\Resource\FileRepository\isFrontend(), TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Resource\FileRepository\reapplySorting().

◆ findByUid()

TYPO3\CMS\Core\Resource\FileRepository::findByUid ( int  $uid)

◆ isFrontend()

TYPO3\CMS\Core\Resource\FileRepository::isFrontend ( )
protected

Function to return the current application type based on $GLOBALS['TSFE']. This function can be mocked in unit tests to be able to test frontend behaviour.

Definition at line 176 of file FileRepository.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Resource\FileRepository\findByRelation(), and TYPO3\CMS\Core\Resource\FileRepository\findByUid().

◆ reapplySorting()

FileReference [] TYPO3\CMS\Core\Resource\FileRepository::reapplySorting ( array  $itemList)
protected

As sorting might have changed due to workspace overlays, PHP does the sorting again.

Parameters
FileReference[]$itemList
Returns
FileReference[]

Definition at line 154 of file FileRepository.php.

References TYPO3\CMS\Core\Resource\FileReference\getReferenceProperty().

Referenced by TYPO3\CMS\Core\Resource\FileRepository\findByRelation().