[TYPO3-mvc] Persist objects after adding or updating

Matthew Colton mat.colton at web-xs.de
Sat Jul 26 13:08:09 CEST 2014


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