homepage: add social action in evaluation serialisation

This commit is contained in:
Julien Fastré 2022-02-01 14:14:55 +01:00
parent de1dddbb85
commit 5d2cb8c712
6 changed files with 16 additions and 14 deletions

View File

@ -44,7 +44,6 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte
*/ */
public function normalize($object, ?string $format = null, array $context = []) public function normalize($object, ?string $format = null, array $context = [])
{ {
dump($object);
$entity = $this->entityManager $entity = $this->entityManager
->getRepository($object->getRelatedEntityClass()) ->getRepository($object->getRelatedEntityClass())
->find($object->getRelatedEntityId()); ->find($object->getRelatedEntityId());

View File

@ -99,7 +99,7 @@ class AccompanyingPeriodWorkEvaluationApiController
if ($request->query->getBoolean('countOnly', false)) { if ($request->query->getBoolean('countOnly', false)) {
return new JsonResponse( return new JsonResponse(
$this->serializer->serialize(new Counter($total), 'json', ['groups' => 'read']), $this->serializer->serialize(new Counter($total), 'json', ['groups' => ['read']]),
JsonResponse::HTTP_OK, JsonResponse::HTTP_OK,
[], [],
true true
@ -117,7 +117,7 @@ class AccompanyingPeriodWorkEvaluationApiController
$collection = new Collection($works, $paginator); $collection = new Collection($works, $paginator);
return new JsonResponse( return new JsonResponse(
$this->serializer->serialize($collection, 'json', ['groups' => 'read']), $this->serializer->serialize($collection, 'json', ['groups' => ['read', 'read:evaluation:include-work']]),
JsonResponse::HTTP_OK, JsonResponse::HTTP_OK,
[], [],
true true

View File

@ -44,7 +44,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
{ {
/** /**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read","read:accompanyingPeriodWork:light"})
*/ */
private ?AccompanyingPeriod $accompanyingPeriod = null; private ?AccompanyingPeriod $accompanyingPeriod = null;
@ -63,26 +63,26 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/** /**
* @ORM\Column(type="datetime_immutable") * @ORM\Column(type="datetime_immutable")
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/ */
private ?DateTimeImmutable $createdAt = null; private ?DateTimeImmutable $createdAt = null;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/ */
private bool $createdAutomatically = false; private bool $createdAutomatically = false;
/** /**
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/ */
private string $createdAutomaticallyReason = ''; private string $createdAutomaticallyReason = '';
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/ */
private ?User $createdBy = null; private ?User $createdBy = null;
@ -90,7 +90,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) * @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"accompanying_period_work:create"}) * @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"}) * @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Assert\GreaterThan(propertyPath="startDate", * @Assert\GreaterThan(propertyPath="startDate",
* message="accompanying_course_work.The endDate should be greater than the start date" * message="accompanying_course_work.The endDate should be greater than the start date"
* ) * )
@ -122,7 +122,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light", "read:evaluation:include-work"})
*/ */
private ?int $id = null; private ?int $id = null;
@ -135,7 +135,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/** /**
* @ORM\ManyToMany(targetEntity=Person::class) * @ORM\ManyToMany(targetEntity=Person::class)
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person") * @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:edit"}) * @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"accompanying_period_work:create"}) * @Serializer\Groups({"accompanying_period_work:create"})
*/ */
@ -151,8 +151,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/** /**
* @ORM\ManyToOne(targetEntity=SocialAction::class) * @ORM\ManyToOne(targetEntity=SocialAction::class)
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:create"}) * @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Context(normalizationContext={"groups"={"read"}}, groups={"read:accompanyingPeriodWork:light"})
*/ */
private ?SocialAction $socialAction = null; private ?SocialAction $socialAction = null;
@ -160,7 +161,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* @ORM\Column(type="date_immutable") * @ORM\Column(type="date_immutable")
* @Serializer\Groups({"accompanying_period_work:create"}) * @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"}) * @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/ */
private ?DateTimeImmutable $startDate = null; private ?DateTimeImmutable $startDate = null;

View File

@ -39,6 +39,8 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* targetEntity=AccompanyingPeriodWork::class, * targetEntity=AccompanyingPeriodWork::class,
* inversedBy="accompanyingPeriodWorkEvaluations" * inversedBy="accompanyingPeriodWorkEvaluations"
* ) * )
* @Serializer\Groups({"read:evaluation:include-work"})
* @Serializer\Context(normalizationContext={"groups"={"read:accompanyingPeriodWork:light"}}, groups={"read:evaluation:include-work"})
*/ */
private ?AccompanyingPeriodWork $accompanyingPeriodWork = null; private ?AccompanyingPeriodWork $accompanyingPeriodWork = null;

View File

@ -44,6 +44,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz
*/ */
public function normalize($object, ?string $format = null, array $context = []): array public function normalize($object, ?string $format = null, array $context = []): array
{ {
dump($context);
$initial = $this->normalizer->normalize($object, $format, array_merge( $initial = $this->normalizer->normalize($object, $format, array_merge(
$context, $context,
[self::IGNORE_EVALUATION => spl_object_hash($object)] [self::IGNORE_EVALUATION => spl_object_hash($object)]

View File

@ -109,7 +109,6 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
$user = new stdClass(); $user = new stdClass();
$user->id = 0; $user->id = 0;
$user->type = 'user'; $user->type = 'user';
dump($user);
$this->client->request( $this->client->request(
Request::METHOD_PATCH, Request::METHOD_PATCH,