[TYPO3-mvc] FAL - create FileReference from within a frontend controller action
Helmut Hummel
helmut.hummel at typo3.org
Fri Oct 31 16:19:05 CET 2014
Hi Jan!
On 31.10.14 14:39, Jan Kornblum wrote:
> But i still get the same error with "setOriginalResource". Something
> else must be wrong with my code:
Which error?
> // Move the file from /tmp/anything
> $movedFile = $storage->addFile($filePath, $targetFolder, $fileName);
$movedFile is now a FAL File Object (\TYPO3\CMS\Core\Resource\File)
> // Create new file reference
> $newFile = $storage->getFile($movedFile->getIdentifier());
You don't need this line, you already have a file object.
> $newFileReference =
> $this->objectManager->get('Xxx\\Yyy\\Domain\\Model\\FileReference');
> $newFileReference->setOriginalResource($newFile);
$newFileReference->setOriginalResource($movedFile);
Should be enough.
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