[TYPO3-mvc] Using the resourceFactory
Philipp
philippwrann at gmx.at
Fri Mar 22 16:08:11 CET 2013
Hey
How can i use the resourceFactory to create a file Reference? I cant find the option to set the uid_foreign...
The problem is that the FAL is bugged or - i dont know exactly - the extbase SQL Join.
I have to write an import for data, this is absolutely no problem using the models and repos everything works really smooth.
But i cant add images to my aggregate. It all starts with the fact, that i cant use an objectStorage filled with fileReference Objects.
This property:
/**
* Images
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Core\Resource\FileReference>
*/
protected $images;
throws this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM sys_file_reference LEFT JOIN ON sys_file_reference.uid_local = .uid WHER' at line 1: SELECT .* FROM sys_file_reference LEFT JOIN ON sys_file_reference.uid_local = .uid WHERE (sys_file_reference.uid_foreign = '611' AND sys_file_reference.tablenames = 'tx_regionalobject_domain_model_regionalobject') AND sys_file_reference.hidden=0 AND sys_file_reference.deleted=0 ORDER BY sys_file_reference.sorting_foreign ASC
So i thought instead of
$aggregate->addImage($newFileObject);
i use the resourceFactory to do get the job done.
Tried it that way:
$resourceFactory = $this->objectManager->get('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
$storage = $resourceFactory->getStorageObject(4);
/* @var $resourceFactory \TYPO3\CMS\Core\Resource\ResourceFactory */
$file = $resourceFactory->createFileObject(array('name'=>'Test','identifier'=>'test.png','storage'=>$storage));
$reference = $resourceFactory->createFileReferenceObject(array('uid_local'=>$file->getUid()));
So, well - how can i now connect the reference with my aggregate? I just need to add the uid_foreign to the reference and persist everything.
Please help me.
More information about the TYPO3-project-typo3v4mvc
mailing list