serialize new activity when id's not yet defined

This commit is contained in:
Mathieu Jaumotte 2021-05-28 10:24:13 +02:00
parent 56242f9b5a
commit a19fd51600

View File

@ -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;
}