I am creating a REST API using Apigility with Zend Framework 2. In this API, I have a code-related REST service, and I encounter strange behavior when I try to delete an object. I use the delete method of my TableGateway object to delete the data passed to the delete method of the Resource file:
public function delete($id)
{
$this->getTable('order')->delete(array('id' => $id));
return array("status" => "deleted", "id" => $id);
}
I tested this feature using the Postman REST client and got the answer:
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title":"Unprocessable Entity",
"status":422,
"detail":"Unable to delete entity."
}
However, when I checked the mysql database, the object in question was deleted correctly. There were no signs of error.
What could be the reason for this error?
Update: The code displays the lines after calling the delete function of the TableGateway function. This means that the answer is probably built after the function call, and the return value that I return is ignored.