Update CommandDenormalizer to use API Platform name converter and handle null cases

This commit is contained in:
Francis Hilaire 2026-05-28 15:18:54 +02:00
parent 55f2ea3d51
commit 1a954e88cd
No known key found for this signature in database
GPG key ID: 3392F830BF33D421
2 changed files with 3 additions and 3 deletions

View file

@ -32,7 +32,7 @@
<service id="sylius_api.denormalizer.command" class="Sylius\Bundle\ApiBundle\Serializer\Denormalizer\CommandDenormalizer">
<argument type="service" id="api_platform.serializer.normalizer.item" />
<argument type="service" id="serializer.name_converter.metadata_aware" />
<argument type="service" id="api_platform.name_converter" on-invalid="ignore" />
<tag name="serializer.normalizer" />
</service>

View file

@ -24,7 +24,7 @@ final class CommandDenormalizer implements DenormalizerInterface
{
public function __construct(
private DenormalizerInterface $itemNormalizer,
private NameConverterInterface $nameConverter,
private ?NameConverterInterface $nameConverter,
) {
}
@ -70,6 +70,6 @@ final class CommandDenormalizer implements DenormalizerInterface
private function normalizeFieldName(string $field, string $class): string
{
return $this->nameConverter->normalize($field, $class);
return $this->nameConverter ? $this->nameConverter->normalize($field, $class) : $field;
}
}