diff --git a/src/Manager/ModelManager.php b/src/Manager/ModelManager.php index 9690f64..d5be41b 100644 --- a/src/Manager/ModelManager.php +++ b/src/Manager/ModelManager.php @@ -7,7 +7,7 @@ use FluxSE\OdooApiClient\Model\BaseInterface; use FluxSE\OdooApiClient\Operations\Object\ExecuteKw\Options\OptionsInterface; use FluxSE\OdooApiClient\Operations\Object\ExecuteKw\RecordOperationsInterface; -use FluxSE\OdooApiClient\Serializer\OdooNormalizer; +use FluxSE\OdooApiClient\Serializer\OdooRelationsNormalizer; use LogicException; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -38,7 +38,7 @@ public function update(BaseInterface $model, ?OptionsInterface $options = null): } $normalizedModel = (array) $this->normalizer->normalize($model, null, [ - OdooNormalizer::NORMALIZE_FOR_UPDATE => true, + OdooRelationsNormalizer::NORMALIZE_FOR_UPDATE => true, ]); return $this->recordOperations->write( $model::getOdooModelName(), diff --git a/src/Serializer/OdooNormalizer.php b/src/Serializer/OdooNormalizer.php index ba4c0dc..1b993e7 100644 --- a/src/Serializer/OdooNormalizer.php +++ b/src/Serializer/OdooNormalizer.php @@ -14,8 +14,6 @@ final class OdooNormalizer extends ObjectNormalizer { - public const NORMALIZE_FOR_UPDATE = 'normalize_for_update'; - public function getSupportedTypes(?string $format): array { return [ diff --git a/src/Serializer/OdooRelationsNormalizer.php b/src/Serializer/OdooRelationsNormalizer.php index ebd66de..40a89d4 100644 --- a/src/Serializer/OdooRelationsNormalizer.php +++ b/src/Serializer/OdooRelationsNormalizer.php @@ -15,6 +15,8 @@ final class OdooRelationsNormalizer implements NormalizerInterface, NormalizerAw { use NormalizerAwareTrait; + public const NORMALIZE_FOR_UPDATE = 'normalize_for_update'; + public function getSupportedTypes(?string $format): array { return ['native-array' => true]; @@ -26,7 +28,7 @@ public function supportsNormalization($data, string $format = null, array $conte return false; } - $normalizeForUpdate = $context[OdooNormalizer::NORMALIZE_FOR_UPDATE] ?? false; + $normalizeForUpdate = $context[self::NORMALIZE_FOR_UPDATE] ?? false; if (!$normalizeForUpdate) { return false; } diff --git a/tests/Serializer/OdooNormalizerTest.php b/tests/Serializer/OdooNormalizerTest.php index b7426af..6e24f6b 100644 --- a/tests/Serializer/OdooNormalizerTest.php +++ b/tests/Serializer/OdooNormalizerTest.php @@ -4,7 +4,7 @@ use FluxSE\OdooApiClient\Model\OdooRelation; use FluxSE\OdooApiClient\Serializer\Factory\SerializerFactory; -use FluxSE\OdooApiClient\Serializer\OdooNormalizer; +use FluxSE\OdooApiClient\Serializer\OdooRelationsNormalizer; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Serializer; use Tests\FluxSE\OdooApiClient\TestModel\Object\Res\Partner; @@ -33,7 +33,7 @@ public function testNormalizeForUpdate(): void ]); $arr = $this->serializer->normalize($object, null, [ - OdooNormalizer::NORMALIZE_FOR_UPDATE => true, + OdooRelationsNormalizer::NORMALIZE_FOR_UPDATE => true, ]); $this->assertEquals([ @@ -55,7 +55,7 @@ public function testNormalizeForUpdateWithNullData(): void ]); $arr = $this->serializer->normalize($object, null, [ - OdooNormalizer::NORMALIZE_FOR_UPDATE => true, + OdooRelationsNormalizer::NORMALIZE_FOR_UPDATE => true, ]); $this->assertEquals([