TYPO3CMS-Reference-CoreApi
TYPO3CMS-Reference-CoreApi copied to clipboard
Document how to get referenced files in CLI mode (FileRepository::findByRelation does not / may not work in CLI)
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Fal/UsingFal/ExamplesFileFolder.html#getting-referenced-files documents how to fetch FAL objects.
However this may not (does not) work in CLI context. Have not tested BE context.
For now, a note might be helpful there, until this can be further resolved.
Getting Referenced files This snippet shows how to retrieve FAL items that have been attached to some other element, in this case the "media" field of the "pages" table:
EXT:some_extension/Classes/SomeClass.php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Resource\FileRepository;
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$fileObjects = $fileRepository->findByRelation('pages', 'media', $uid);
```> where $uid is the id of some page. The return value is an array of \TYPO3\CMS\Core\Resource\FileReference objects.
Needs to be further analyzed.
## TYPO3 forge issues
* Reported findings in issue https://forge.typo3.org/issues/99442
* Possible duplicate: https://forge.typo3.org/issues/61344