[TYPO3-mvc] extbase way of accessing folder based file collection
Frans Saris
franssaris at gmail.com
Sun Jun 23 10:02:52 CEST 2013
Op 23 jun. 2013 06:35 schreef "Domi" <djgarms at gmail.com> het volgende:
>
> Hi Frans
>
>>
>> /**
>> * @param $uid collection uid from flexform
>> *
>> * @return array|void
>> */
>> protected function getFileCollectionItems($uid) {
>> /** @var $fileCollection
>> \TYPO3\CMS\Core\Resource\**Collection\**AbstractFileCollection */
>> $fileCollection =
$this->fileCollectionRepository->findByUid($uid);
>> $fileCollection->loadContents();
>> $items = $fileCollection->getItems();
>>
>> foreach ($items as $item) {
>> /** @var FileReference $item */
>> $files[] = $item->toArray();
>> }
>>
>> return $files;
>> }
>>
> I did this and it works!
>
>
>
>> so this will not work:
>>
>> $fileCollection->loadContents();
>> $items = $fileCollection->getItems();
>>
>> return $fileCollection->loadContents();
>
>
> This doesn't work for the FolderBasedFileCollection. I tried all options
but items always remain empty.
>
> Any ideas why it's not working?
> Thanks,
> Dominic
Try this:
$fileCollection->loadContents();
return $fileCollection->getItems();
First load content and then get items.
Gr. Frans
More information about the TYPO3-project-typo3v4mvc
mailing list