From a19fd5160085ecfb792fa37b26a13e7ad1b49434 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 28 May 2021 10:24:13 +0200 Subject: [PATCH] serialize new activity when id's not yet defined --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 5834cd7cd..733a6a1bc 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -35,6 +35,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; /** * Class Activity @@ -43,6 +44,9 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\Entity() * @ORM\Table(name="activity") * @ORM\HasLifecycleCallbacks() + * @DiscriminatorMap(typeProperty="type", mapping={ + * "activity"=Activity::class + * }) */ /* @@ -64,7 +68,7 @@ class Activity implements HasCenterInterface, HasScopeInterface * @ORM\GeneratedValue(strategy="AUTO") * @Groups({"read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") @@ -113,6 +117,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") + * @Groups({"read"}) */ private ?AccompanyingPeriod $accompanyingPeriod = null; @@ -164,7 +169,7 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->users = new ArrayCollection(); } - public function getId(): int + public function getId(): ?int { return $this->id; }