[v3] ReadListener is triggered for write type operation
API Platform version(s) affected: v3.0.0-rc.2
Description
ReadListener triggered instead of WriteListener for POST, PATCH, PUT and DELETE with parameter in URL.
In other words, provider is expected instead of processor when using url parameter
How to reproduce
Given following ApiResouce class that has id parameter
#[ApiResource(
shortName: 'Warehouse',
operations: [
new Patch(
uriTemplate: '/someresource/{id}.{_format}',
input: SomeCommand::class,
output: false,
processor: SomeProcessor::class
)
],
routePrefix: 'admin'
)]
class SomeResouce
{
When calling it it throws following error
Provider not found on operation \"_api_/someresouces/{id}.{_format}_patch\"
Possible Solution
As I checked ApiPlatform\Symfony\EventListener\ReadListener::onKernelRequest, $operation->canRead() is returning null due to which it is not returning void for this event and keeps continuing.
if (!$operation || !($operation->canRead() ?? true) || !$attributes['receive'] || (!$operation->getUriVariables() && !$request->isMethodSafe())) {
return;
}
Additional Context
Sorry, seems like this is not an issue. Since I have used custom resource class instead of entity, it seems I was missing read and write parameter like this
[ApiResource(
shortName: 'Warehouse',
operations: [
new Patch(
uriTemplate: '/someresource/{id}.{_format}',
input: SomeCommand::class,
output: false,
processor: SomeProcessor::class,
read: false,
write: true
)
],
routePrefix: 'admin'
)]
Would it be valid case to automatically sett read and write property based on operation type like get, or post or put or patch, etc? Otherwise we can close the issue imo