-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
Description
RFC
Q | A |
---|---|
Proposed Version(s) | 1.6.2 |
BC Break? | No |
Laminas\ApiTools\Rest\RestController::delete($id)
If I return own Laminas\Http\Response on line 443 as $result, the event 'delete.post' won't be triggered.
try {
$result = $this->getResource()->delete($id);
} catch (Throwable $e) {
return $this->createApiProblemFromException($e);
} catch (Exception $e) {
return $this->createApiProblemFromException($e);
}
$result = $result ?: new ApiProblem(422, 'Unable to delete entity.');
if ($this->isPreparedResponse($result)) {
return $result;
}
$response = $this->getResponse();
$response->setStatusCode(204);
$events->trigger('delete.post', $this, ['id' => $id]);
return $response;
Scenario
Resource deletion leads to change of other resources and client must be notified about it. So we return 200 with response body. But if other modules listen for 'delete.post' and perform extra actions - they won't be notified about resource deletion.
Suggestion
Check if $result is instance of Laminas\Http\Response separately from ApiProblem / ApiProblemResponse and trigger 'delete.post' before returning it.