Skip to content

Commit

Permalink
fix(symfony): no read should throw on wrong uri variables
Browse files Browse the repository at this point in the history
fixes #6358
  • Loading branch information
soyuka committed May 7, 2024
1 parent 04474e4 commit 97746f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/State/Processor/SerializeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
// @see ApiPlatform\State\Processor\RespondProcessor
$context['original_data'] = $data;

$class = $operation->getClass();
if ($request->attributes->get('_api_resource_class') !== $operation->getClass()) {
$class = $request->attributes->get('_api_resource_class');
trigger_deprecation('api-platform/core', '3.3', 'The resource class on the router is not the same as the operation\'s class which leads to wrong behaviors. Prefer using "stateOptions" if you need to change the entity class.');
}

$serializerContext = $this->serializerContextBuilder->createFromRequest($request, true, [
'resource_class' => $operation->getClass(),
'resource_class' => $class,
'operation' => $operation,
]);

Expand Down

0 comments on commit 97746f8

Please sign in to comment.