docs
docs copied to clipboard
Messenger & DELETE operation
I'm unable to get the messenger integration working with a DELETE operation. Would be great if I can be pointed in the right direction; I'll do a docs PR if I can get it working.
From @dunglas comment I recon this should be supported, so I'm struggling with the configuration.
For a PATCH operation, the following works for me:
'patch' => [
'method' => 'patch',
'path' => '/my-resource',
'messenger' => 'input',
'read' => false,
'input' => MyResourcePatchCommand::class,
'output' => false,
],
For a DELETE operation, the following does not work for me:
(changing input to true or persist does not change the outcome)
'delete' => [
'method' => 'delete',
'path' => '/my-resource',
'messenger' => 'input',
'read' => false,
'input' => MyResourceDeleteCommand::class,
'output' => false,
],
It results in the error below; do I need to set a controller explicitly for delete commands?
{
"@context": "\/api\/contexts\/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Could not resolve argument $data of \u0022api_platform.action.delete_item()\u0022, maybe you forgot to register the controller as a service or missed tagging it with the \u0022controller.service_arguments\u0022?",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "\/srv\/api\/vendor\/symfony\/http-kernel\/Controller\/ArgumentResolver\/NotTaggedControllerValueResolver.php",
"line": 79,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver",
"short_class": "NotTaggedControllerValueResolver",
"class": "Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver\\NotTaggedControllerValueResolver",
"type": "-\u003E",
"function": "resolve",
"file": "\/srv\/api\/vendor\/symfony\/http-kernel\/Controller\/ArgumentResolver\/TraceableValueResolver.php",
"line": 58,
"args": [
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata"
]
]
},
.....
}
In the context of this issue: Is it still valid to early return in the DeserializeListener for DELETE methods? Because if I remove this line, the command is sent to the handler.
https://github.com/api-platform/core/blob/7cea036b2732d6f686ed63e307fc863d3c6c045d/src/EventListener/DeserializeListener.php#L75
If the awnser is no; would a PR be accepted changing
'DELETE' === $method
to
('DELETE' === $method && messenger attribute is not set to input)
Currently facing the same issue (that was already reported here: https://github.com/api-platform/core/issues/3082).
DELETE requests being mutations, it would make sense to be able to handle them too imho.
I guess this issue should be moved to api-platform/core, but looking forward to @darthf1 's proposal anyway :+1: