mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Only run PartDenormalizer when importing files, otherwise it causes problems with API platform
This fixes issue #800
This commit is contained in:
parent
39763b84d5
commit
a6116398a8
1 changed files with 8 additions and 1 deletions
|
@ -94,7 +94,14 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Norm
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
|
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
|
private function normalizeKeys(array &$data): array
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue