[TYPO3-mvc] Persist objects after adding or updating

Dirk Wenzel wenzel at webfox03.de
Sat Jul 26 16:04:14 CEST 2014


Hi Matthew,
Actualy I tried to redirect with my newly created object as argument 
($newObject in my example code).
I guess I oversimplified my example. The actual code can be found here:
https://github.com/dwenzel/placements/commit/d5b28d3b8a4a105bce17d5a5bc6d2a52bc821247

Cheers
Dirk


Am 26.07.14 13:08, schrieb Matthew Colton:
> Hi Dirk,
> hmm, wierd, the following works just fine for me:
>
> public function createAction(\MY\Ext\Domain\Model\Link $link,
> \MY\Ext\Domain\Model\Event $event) {
>    $this->linkRepository->add($link);
>
> $this->flashMessageContainer->add(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_myext.flash_msg.link_created',
> 'myext'));
>    $this->redirect('edit','Event', NULL, array('event' => $event));
> }
>
> No need for explicitly persisting the object.
>
> Are you trying to redirect with $newObject being the object you are
> about to create? That might not work, have not tried it yet. In that
> case might actually have to persist the object first.
> I know you have to persist an object before assigning it to another
> object. That is because the identifier is not available before
> persisting. At least AFAIK. :)
>
> Cheers,
> Matthew
>
> Am 26.07.2014 10:32, schrieb Dirk Wenzel:
>> Hi Matthew,
>> thanks for your quick reply.
>> It seems for the createAction redirecting doesn't work when ommiting
>> the persistAll() call. But forwarding does.
>>
>> I got an error
>> #1260881688: Could not serialize Domain Object <Object> It is neither
>> an Entity with identity properties set, nor a Value Object.
>> when calling
>> $this->redirect('show', NULL, NULL, array('position'=>$newObject), ...);
>>
>> So I conclude:
>> Calling forward(...) first finishes the createAction which triggers
>> persisting the newly created object.
>> Calling redirect(...) doesn't finishes the createAction and therefore
>> the object can not be serialized...
>>
>> Cheers
>> Dirk
>>
>> Am 26.07.14 09:30, schrieb Matthew Colton:
>>> no, you don't have to persist the object in that case.
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>>
>


More information about the TYPO3-project-typo3v4mvc mailing list