Reputation: 1454
i am learning how to deal with files and file-refences in TYPO3. This line get me the correct file objects:
$fileObject = $fileRepository->findByRelation('fe_users', 'image', $uidOfUser);
But how do i get the file identifier from this object? (In fluid it would be no problem, but i can't use fluid here).
Thanks?
Upvotes: 1
Views: 472
Reputation: 6480
First of all FileRepository::findByRelation()
returns a list of file reference objects, not a single file reference:
$fileReferences = $fileRepository->findByRelation('fe_users', 'image', $uidOfUser);
Then you can iterate the file references or pick the first to retrieve the identifier:
if (!empty($fileReferences[0])) {
$fileIdentifier = $fileReferences[0]->getIdentifier();
}
Notice that you can also get no file references at all, thus an empty list. So make sure the reference you try to access actually exists.
Upvotes: 1