[TYPO3-mvc] FAL - create FileReference from within a frontend controller action

Jan Kornblum jan.kornblum at gmx.de
Fri Oct 31 17:10:24 CET 2014


Hi Helmut!

wow, great! That works - can't believe it ;)

>> Hmm, what i don't understand: I want to create a FilereReference
>> object, but after the empty object has been created i should use an
>> additional method (setOriginalResource) which itself expects such an
>> (not yet existing) object as given parameter. How should this work?
>
> The one is the Extbase FileReference model and the other one (you need to 
> set) is the FAL FileReference.

Thanks for this hint! I was blind, didn't know that there are two 
different FileReference models...

> But for your use case it would be easier to add another method to your 
> Extbase FileReference Model like that:
>
> https://gist.github.com/helhum/9a274ac1c29b50eedd71
>
> Then do this in your controller:
>
> $movedFile = $storage->addFile($filePath, $targetFolder, $fileName);
> $newFileReference =
> $this->objectManager->get('Xxx\\Yyy\\Domain\\Model\\FileReference');
> $newFileReference->setFile($movedFile);
>
>
>> Sometimes Extbase is really hard, i've already spent so many hours with
>> this problem :(
>
> It's very easy to mix things up in this area, so did I.

Thanks a lot for all your help!

Have a nice weekend, Jan




More information about the TYPO3-project-typo3v4mvc mailing list