comment = new CommentEmbeddable(); } public function getComment(): CommentEmbeddable { return $this->comment; } public function getCreatedAt(): ?DateTimeInterface { return $this->createdAt; } public function getCreatedBy(): ?User { return $this->createdBy; } public function getFreeText(): ?string { return $this->freeText; } /** * GETTERS. */ public function getId(): ?int { return $this->id; } public function getKind(): ?PersonResourceKind { return $this->kind; } public function getPerson(): ?Person { return $this->person; } public function getPersonOwner(): ?Person { return $this->personOwner; } public function getThirdParty(): ?ThirdParty { return $this->thirdParty; } public function getUpdatedAt(): ?DateTimeInterface { return $this->updatedAt; } public function getUpdatedBy(): ?User { return $this->updatedBy; } public function setComment(?CommentEmbeddable $comment): self { if (null === $comment) { $this->comment->setComment(''); return $this; } $this->comment = $comment; return $this; } public function setCreatedAt(DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function setCreatedBy(?User $createdBy): self { $this->createdBy = $createdBy; return $this; } /** * SETTERS. */ public function setFreeText(?string $freeText): self { $this->freeText = $freeText; if ('' !== $freeText && null !== $freeText) { $this->setPerson(null); $this->setThirdParty(null); } return $this; } public function setKind(?PersonResourceKind $kind): self { $this->kind = $kind; return $this; } public function setPerson(?Person $person): self { $this->person = $person; if (null !== $person) { $this->setFreeText(''); $this->setThirdParty(null); } return $this; } public function setPersonOwner(?Person $personOwner): self { $this->personOwner = $personOwner; return $this; } public function setThirdParty(?ThirdParty $thirdParty): self { $this->thirdParty = $thirdParty; if (null !== $thirdParty) { $this->setFreeText(''); $this->setPerson(null); } return $this; } public function setUpdatedAt(DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function setUpdatedBy(?User $updatedBy): self { $this->updatedBy = $updatedBy; return $this; } /** * @Assert\Callback */ public function validate(ExecutionContextInterface $context, $payload) { if ($this->person === null && $this->thirdParty === null && $this->freeText === null ) { $context->buildViolation('You must associate at least one entity') ->atPath('person') ->addViolation(); } } }