Skip to content

Commit a611639

Browse files
committed
Only run PartDenormalizer when importing files, otherwise it causes problems with API platform
This fixes issue #800
1 parent 39763b8 commit a611639

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Serializer/PartNormalizer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ public function normalize($object, string $format = null, array $context = []):
9494

9595
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
9696
{
97-
return !isset($context[self::ALREADY_CALLED]) && is_array($data) && is_a($type, Part::class, true);
97+
//Only denormalize if we are doing a file import operation
98+
if (!($context['partdb_import'] ?? false)) {
99+
return false;
100+
}
101+
102+
//Only make the denormalizer available on import operations
103+
return !isset($context[self::ALREADY_CALLED])
104+
&& is_array($data) && is_a($type, Part::class, true);
98105
}
99106

100107
private function normalizeKeys(array &$data): array

0 commit comments

Comments
 (0)