diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96685b5f0..ff62b029c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to
## Unreleased
+* [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495)
* [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493)
* [parcours] autosave of the pinned comment for draft accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/477)
* [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472)
diff --git a/src/Bundle/ChillMainBundle/Entity/UserJob.php b/src/Bundle/ChillMainBundle/Entity/UserJob.php
index 5f0bea45d..99db5d4f1 100644
--- a/src/Bundle/ChillMainBundle/Entity/UserJob.php
+++ b/src/Bundle/ChillMainBundle/Entity/UserJob.php
@@ -40,6 +40,7 @@ class UserJob
* @var array|string[]A
* @ORM\Column(name="label", type="json")
* @Serializer\Groups({"read", "docgen:read"})
+ * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
protected array $label = [];
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyEvaluations.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyEvaluations.vue
index 7cd40f45a..a872a2f43 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyEvaluations.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyEvaluations.vue
@@ -42,9 +42,6 @@
{{ $t('show_entity', { entity: $t('the_evaluation') }) }}
-
- {{ $t('show_entity', { entity: $t('the_action') }) }}
-
{{ $t('show_entity', { entity: $t('the_course') }) }}
@@ -102,4 +99,4 @@ export default {
\ No newline at end of file
+
diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php
index 3562c1361..677199ad4 100644
--- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php
+++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php
@@ -16,10 +16,11 @@ use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberUtil;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
+use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
-class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterface
+class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface
{
private string $defaultCarrierCode;
@@ -53,6 +54,10 @@ class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterfac
public function normalize($object, ?string $format = null, array $context = []): string
{
+ if ($format === 'docgen' && null === $object) {
+ return '';
+ }
+
return $this->phoneNumberUtil->formatOutOfCountryCallingNumber($object, $this->defaultCarrierCode);
}
@@ -61,8 +66,18 @@ class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterfac
return 'libphonenumber\PhoneNumber' === $type;
}
- public function supportsNormalization($data, ?string $format = null)
+ public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
- return $data instanceof PhoneNumber;
+ if ($data instanceof PhoneNumber && $format === 'json') {
+ return true;
+ }
+
+ if ($format === 'docgen' && (
+ $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null)
+ )) {
+ return true;
+ }
+
+ return false;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
index 07c9f526c..ed3200370 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
@@ -124,6 +124,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read", "docgen:read"})
+ * @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DateTimeImmutable $maxDate = null;
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
index fc9b6003a..e8febcf5d 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
+use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
@@ -46,7 +47,10 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz
{
$initial = $this->normalizer->normalize($object, $format, array_merge(
$context,
- [self::IGNORE_EVALUATION => spl_object_hash($object)]
+ [self::IGNORE_EVALUATION => spl_object_hash($object)],
+ [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static function ($object, $format, $context) {
+ return $object->getId();
+ }]
));
// due to bug: https://api-platform.com/docs/core/serialization/#collection-relation