Only run PartDenormalizer when importing files, otherwise it causes problems with API platform

This fixes issue #800
This commit is contained in:
Jan Böhmer 2025-01-05 17:37:02 +01:00
parent 39763b84d5
commit a6116398a8

View file

@ -94,7 +94,14 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Norm
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return !isset($context[self::ALREADY_CALLED]) && is_array($data) && is_a($type, Part::class, true);
//Only denormalize if we are doing a file import operation
if (!($context['partdb_import'] ?? false)) {
return false;
}
//Only make the denormalizer available on import operations
return !isset($context[self::ALREADY_CALLED])
&& is_array($data) && is_a($type, Part::class, true);
}
private function normalizeKeys(array &$data): array