Skip to content

Commit

Permalink
chore: inject FileRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
smichaelsen committed Aug 29, 2024
1 parent d766aa9 commit 5106ba6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/DataProviding/Traits/FileReferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;

trait FileReferences
{
private FileRepository $fileRepository;

public function injectFileRepository(FileRepository $fileRepository): void
{
$this->fileRepository = $fileRepository;
}

/**
* @return FileReference[]
*/
Expand All @@ -17,8 +23,7 @@ protected function loadFileReferences(array $record, string $fieldName, string $
if (empty($localUid)) {
return [];
}
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
return $fileRepository->findByRelation($localTableName, $fieldName, $localUid);
return $this->fileRepository->findByRelation($localTableName, $fieldName, $localUid);
}

protected function loadFileReference(array $record, string $fieldName, string $localTableName = 'tt_content'): ?FileReference
Expand Down

0 comments on commit 5106ba6

Please sign in to comment.