[Flow] RestController - updated Objects are not persisted
Robert Berghegger
r_berghegger at web.de
Mon Oct 14 23:11:01 CEST 2013
Thanks for your quick response Stephen.
I tried that, but it doesn't change anything. And i think i know why.
I noticed that the Object which is passed to the updateAction as
Parameter is the old Object. Since the Object was not changed it is not
persisted.
If i change my routing from:
name: 'Single CD URI'
uriPattern: 'cd/{cd}'
defaults:
'@package': 'Berghegger.CD'
'@controller': 'CD'
to:
name: 'Single CD URI'
uriPattern: 'cd/{cd.__identity}'
defaults:
'@package': 'Berghegger.CD'
'@controller': 'CD'
The Object with updated attributes is passed to the updateAction. I'm
curious to know why this is happening.
Robert
Am 14.10.2013 16:54, schrieb Stephen Bungert:
> I believe persistAll is only called for POST,
>
> you could manually call it in your action.
>
> Stephen,
>
>
> "Robert Berghegger" <r_berghegger at web.de> schrieb im Newsbeitrag
> news:mailman.2018.1381761776.588.flow at lists.typo3.org...
>> Hello everyone,
>>
>> I have a question belonging to the RestController.
>>
>> My routing-setup:
>>
>> -
>> name: 'Single CD URI'
>> uriPattern: 'cd/{cd}'
>> defaults:
>> '@package': 'Berghegger.CD'
>> '@controller': 'CD'
>>
>> -
>> name: 'CD List URI'
>> uriPattern: 'cd'
>> defaults:
>> '@package': 'Berghegger.CD'
>> '@controller': 'CD'
>>
>> Everytime I create an CD-Object with a HTTP-POST to:
>>
>> http://flow.robert-pc/index.php/cd
>>
>> with a Body like this:
>>
>> cd[title]=Eternal Movement&cd[artist]=Tides from nebula
>>
>> It is successfull persited and I can retreive the Object with a HTTP-GET
>> to:
>>
>> http://flow.robert-pc/index.php/cd/b068de1b-e53e-706f-a17e-a7b08176ca92
>>
>> the result looks like this:
>>
>> 1. {
>> 2. "artist": "Tides from nebula",
>> 3. "title": "Eternal Movement",
>> 4. "__identity": "b068de1b-e53e-706f-a17e-a7b08176ca92"
>> 5. }
>> I can also delete this object. So far, so good.
>>
>> But when I try to update this Object with a HTTP-PUT the changes are not
>> persisted, though the updateAction is triggered.
>>
>> /**
>> *
>> * @param \Berghegger\CD\Domain\Model\CD $cd The updated CD-Object
>> * @return void
>> */
>> public function updateAction(CD $cd) {
>> $this->cdRepository->update($cd);
>> $this->response->setStatus(201);
>>
>> }
>>
>> What am i doing wrong?
>>
>> Kind regards,
>>
>> Robert
>>
>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list