comment = new CommentEmbeddable(); $this->privateComment = new PrivateCommentEmbeddable(); $this->persons = new ArrayCollection(); $this->professionals = new ArrayCollection(); $this->invites = new ArrayCollection(); } public function addInvite(?Invite $invite): self { if (null !== $invite) { $this->invites[] = $invite; } return $this; } public function addPerson(?Person $person): self { if (null !== $person) { $this->persons[] = $person; } return $this; } public function addProfessional(?ThirdParty $professional): self { if (null !== $professional) { $this->professionals[] = $professional; } return $this; } public function getAccompanyingPeriod(): ?AccompanyingPeriod { return $this->accompanyingPeriod; } public function getActivity(): ?Activity { return $this->activity; } public function getCalendarRange(): ?CalendarRange { return $this->calendarRange; } public function getCancelReason(): ?CancelReason { return $this->cancelReason; } public function getComment(): CommentEmbeddable { return $this->comment; } public function getEndDate(): ?DateTimeImmutable { return $this->endDate; } public function getId(): ?int { return $this->id; } /** * @return Collection|Invite[] */ public function getInvites(): Collection { return $this->invites; } public function getLocation(): ?Location { return $this->location; } public function getMainUser(): ?User { return $this->mainUser; } /** * @return Collection|Person[] */ public function getPersons(): Collection { return $this->persons; } public function getPersonsAssociated(): array { if (null !== $this->accompanyingPeriod) { $personsAssociated = []; foreach ($this->accompanyingPeriod->getParticipations() as $participation) { if ($this->persons->contains($participation->getPerson())) { $personsAssociated[] = $participation->getPerson(); } } return $personsAssociated; } return []; } public function getPersonsNotAssociated(): array { if (null !== $this->accompanyingPeriod) { $personsNotAssociated = []; foreach ($this->persons as $person) { if (!in_array($person, $this->getPersonsAssociated(), true)) { $personsNotAssociated[] = $person; } } return $personsNotAssociated; } return []; } public function getPrivateComment(): PrivateCommentEmbeddable { return $this->privateComment; } /** * @return Collection|ThirdParty[] */ public function getProfessionals(): Collection { return $this->professionals; } public function getSendSMS(): ?bool { return $this->sendSMS; } public function getStartDate(): ?DateTimeImmutable { return $this->startDate; } public function getStatus(): ?string { return $this->status; } public function getThirdParties(): Collection { return $this->getProfessionals(); } public function getUser(): ?User { return $this->user; } public function getusers(): Collection { return $this->getInvites(); //TODO get users of the invite } public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addPropertyConstraint('startDate', new NotBlank()); $metadata->addPropertyConstraint('startDate', new Range([ 'min' => '2 years ago', 'max' => '+ 2 years', ])); $metadata->addPropertyConstraint('endDate', new NotBlank()); $metadata->addPropertyConstraint('endDate', new Range([ 'min' => '2 years ago', 'max' => '+ 2 years', ])); } public function removeInvite(Invite $invite): self { $this->invites->removeElement($invite); return $this; } public function removePerson(Person $person): self { $this->persons->removeElement($person); return $this; } public function removeProfessional(ThirdParty $professional): self { $this->professionals->removeElement($professional); return $this; } public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self { $this->accompanyingPeriod = $accompanyingPeriod; return $this; } public function setActivity(?Activity $activity): self { $this->activity = $activity; return $this; } public function setCalendarRange(?CalendarRange $calendarRange): self { $this->calendarRange = $calendarRange; return $this; } public function setCancelReason(?CancelReason $cancelReason): self { $this->cancelReason = $cancelReason; return $this; } public function setComment(CommentEmbeddable $comment): self { $this->comment = $comment; return $this; } public function setEndDate(DateTimeImmutable $endDate): self { $this->endDate = $endDate; return $this; } public function setLocation(?Location $location): Calendar { $this->location = $location; return $this; } public function setMainUser(?User $mainUser): self { $this->mainUser = $mainUser; return $this; } public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self { $this->privateComment = $privateComment; return $this; } public function setSendSMS(?bool $sendSMS): self { $this->sendSMS = $sendSMS; return $this; } public function setStartDate(DateTimeImmutable $startDate): self { $this->startDate = $startDate; return $this; } public function setStatus(string $status): self { $this->status = $status; return $this; } public function setUser(?User $user): self { $this->user = $user; return $this; } }