Skip to content

Commit

Permalink
Move constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometee committed Jun 5, 2024
1 parent 42e3472 commit b32704c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Manager/ModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 0 additions & 2 deletions src/Serializer/OdooNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

final class OdooNormalizer extends ObjectNormalizer
{
public const NORMALIZE_FOR_UPDATE = 'normalize_for_update';

public function getSupportedTypes(?string $format): array
{
return [
Expand Down
4 changes: 3 additions & 1 deletion src/Serializer/OdooRelationsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Serializer/OdooNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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([
Expand All @@ -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([
Expand Down

0 comments on commit b32704c

Please sign in to comment.