Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## v5.0.0-alpha.4

### Breaking changes

* `ApiPlatform\State\Provider\DeserializeProvider` no longer accepts a `Symfony\Contracts\Translation\TranslatorInterface` as its fourth constructor argument, as announced by the deprecation added in 4.4. Denormalization violations and their translation are handled by `DenormalizationViolationFactoryInterface`, which moves from the fifth to the fourth position. Anyone constructing the provider by hand, or overriding the `api_platform.state_provider.deserialize` service definition, must drop the translator argument. `api-platform/state` no longer requires `symfony/translation-contracts`.
### Notes

* The internal `ApiPlatform\Symfony\Bundle\ArgumentResolver\CompatibleValueResolverInterface` is removed. It aliased either `ValueResolverInterface` or the Symfony 6 `ArgumentValueResolverInterface` depending on which existed; since the Symfony floor is `^7.4`, only the former can be installed, and Symfony 8 dropped the latter altogether. `PayloadArgumentResolver` now implements `ValueResolverInterface` directly.
Expand Down
1 change: 0 additions & 1 deletion src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ public function register(): void
$app->make(SwaggerUiProvider::class),
$app->make(SerializerInterface::class),
$app->make(SerializerContextBuilderInterface::class),
null,
$app->make(DenormalizationViolationFactoryInterface::class),
);
});
Expand Down
5 changes: 0 additions & 5 deletions src/State/Provider/DeserializeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Symfony\Component\Serializer\Exception\PartialDenormalizationException;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class DeserializeProvider implements ProviderInterface, StopwatchAwareInterface
{
Expand All @@ -35,12 +34,8 @@ public function __construct(
private readonly ?ProviderInterface $decorated,
private readonly SerializerInterface $serializer,
private readonly SerializerContextBuilderInterface $serializerContextBuilder,
?TranslatorInterface $translator = null,
private readonly ?DenormalizationViolationFactoryInterface $violationFactory = null,
) {
if (null !== $translator) {
trigger_deprecation('api-platform/core', '4.4', 'Passing a "%s" to "%s" is deprecated and will be removed in 5.0. Translation is now handled by "%s".', TranslatorInterface::class, self::class, DenormalizationViolationFactoryInterface::class);
}
}

public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
Expand Down
6 changes: 3 additions & 3 deletions src/State/Tests/Provider/DeserializeProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function testDeserializeDelegatesSingleErrorToHandler(): void
$handler->expects($this->once())->method('handle')->with($exception, $operation)
->willThrowException(new \LogicException('handler-threw'));

$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler);
$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler);
$request = new Request(content: '{"status":"invalid"}');
$request->headers->set('CONTENT_TYPE', 'application/json');
$request->attributes->set('input_format', 'json');
Expand Down Expand Up @@ -211,7 +211,7 @@ public function testDeserializeDelegatesPartialErrorToHandler(): void
$handler->expects($this->once())->method('handle')->with($partialException, $operation)
->willThrowException(new \LogicException('handler-threw-partial'));

$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler);
$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler);
$request = new Request(content: '{"status":"invalid"}');
$request->headers->set('CONTENT_TYPE', 'application/json');
$request->attributes->set('input_format', 'json');
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testDeserializeRethrowsPartialErrorWhenHandlerReturnsVoid(): voi
$handler = $this->createMock(DenormalizationViolationFactoryInterface::class);
$handler->expects($this->once())->method('handle');

$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler);
$provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler);
$request = new Request(content: '{"status":"invalid"}');
$request->headers->set('CONTENT_TYPE', 'application/json');
$request->attributes->set('input_format', 'json');
Expand Down
1 change: 0 additions & 1 deletion src/State/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"psr/container": "^1.0 || ^2.0",
"symfony/http-kernel": "^7.4 || ^8.0",
"symfony/serializer": "^7.4 || ^8.0",
"symfony/translation-contracts": "^3.0",
"symfony/deprecation-contracts": "^3.1"
},
"require-dev": {
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bundle/Resources/config/mcp/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
service('api_platform.mcp.state_provider.deserialize.inner'),
service('api_platform.serializer'),
service('api_platform.serializer.context_builder'),
service('translator')->nullOnInvalid(),
]);

$services->set('api_platform.mcp.state_provider.parameter', ParameterProvider::class)
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bundle/Resources/config/state/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
service('api_platform.state_provider.deserialize.inner'),
service('api_platform.serializer'),
service('api_platform.serializer.context_builder'),
null,
service('api_platform.state.denormalization_violation_factory')->nullOnInvalid(),
]);

Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bundle/Resources/config/symfony/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
null,
service('api_platform.serializer'),
service('api_platform.serializer.context_builder'),
null,
service('api_platform.state.denormalization_violation_factory')->nullOnInvalid(),
]);

Expand Down
Loading