Reputation: 913
I use API platform
with Symfony5
, and I created a service to verify a statement if it is correct.
This statement if is correct, I want to change an existing object instead of adding on a POST request.
So, on POST request I created an event with PRE_WRITE
events priorities, and this event calls a service who verifies if the statement is correct if is true, I edit an existing object.
All that work correctly without any problem, but the POST request is always for adding a new object, so, I get a new line on the database table.
Is there any solution, to return 200 responses on the edit object?
Upvotes: 4
Views: 299
Reputation: 1143
Try adding a Response to the kernel.view event like:
....
public function yourEvent(Event $event)
{
// do your service stuff
// ...
$event->setResponse(new Response('ok', 200));
}
Upvotes: 1