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

Helmut Hummel helmut.hummel at typo3.org
Fri Oct 31 12:07:09 CET 2014


Hi!

On 31.10.14 00:54, Jan Kornblum wrote:
> Hi newsgroup,
>
> how can a FileReference be created inside a controller action from a
> given file (stored anywhere in fileadmin)?

Be sure to use a FileReference model like this:

https://github.com/helhum/upload_example/blob/master/Classes/Domain/Model/FileReference.php

Provide a correct mapping configuration for that:
https://github.com/helhum/upload_example/blob/master/ext_typoscript_setup.txt

Don't forget the matchfields in TCA:
https://github.com/helhum/upload_example/blob/master/Configuration/TCA/tx_uploadexample_domain_model_example.php#L183

Then, just create a filereference object:

$fileReference = 
$this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');

and set the original FAL file object you want to reference:

$fileReference->setOriginalResource($falFileReference);

Add $fileReference to your object storage and pass your entity object to 
the repository "update" method so that changes are persisted.

Kind regards,
Helmut

-- 
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-project-typo3v4mvc mailing list