[TYPO3-mvc] extbase way of accessing folder based file collection

Frans Saris franssaris at gmail.com
Wed Jun 19 08:18:14 CEST 2013


Hi Dominic,

could you try this:

/**
	 * @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;
	}



Before you can call getItem() you need to load the items loadContents().
This is for both collection types the sam.

so this will  not work:

	$fileCollection->loadContents();
	$items = $fileCollection->getItems();

	return $fileCollection->loadContents();


gr. Frans



2013/6/19 Domi <djgarms at gmail.com>

> Hi again,
>
> I really don't know where the different is. I use now in my controller
> almost the same code than in media_gallery.
>
> https://github.com/dohomi/**flux_galleria/blob/master/**
> Classes/Controller/**GalleriaController.php<https://github.com/dohomi/flux_galleria/blob/master/Classes/Controller/GalleriaController.php>
>
> In function getFileCollectionItems() there you find the code. The else
> condition works, but I never reached the folder name till now.
>
> Cheers,
>
> Dominic
>
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list