establishments = new ArrayCollection(); $this->debriefings = new ArrayCollection(); $this->events = new ArrayCollection(); } public function __toString() { return (string) $this->getLabel(); } public function getId(): ?int { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } /** * @return Collection */ public function getEstablishments(): Collection { return $this->establishments; } public function addEstablishment(Establishment $establishment): self { if (!$this->establishments->contains($establishment)) { $this->establishments[] = $establishment; } return $this; } public function removeEstablishment(Establishment $establishment): self { $this->establishments->removeElement($establishment); return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getClient(): ?string { return $this->client; } public function setClient(?string $client): self { $this->client = $client; return $this; } public function getFiles(): ?array { usort($this->files, function ($a, $b) { return $a['position'] <=> $b['position']; }); return $this->files; } public function setFiles(array $files): self { $this->files = $files; return $this; } /** * @return Collection */ public function getDebriefings(): Collection { return $this->debriefings; } public function addDebriefing(Debriefing $debriefing): self { if (!$this->debriefings->contains($debriefing)) { $this->debriefings[] = $debriefing; $debriefing->addProject($this); } return $this; } public function removeDebriefing(Debriefing $debriefing): self { if ($this->debriefings->removeElement($debriefing)) { $debriefing->removeProject($this); } return $this; } public function getCaldavEventTag(): string { return sprintf('#{project:%d}', $this->getId()); } /** * @return Collection */ public function getEvents(): Collection { $events = $this->events->toArray(); usort($events, function($a, $b) { return $a->getStartAt() <=> $a->getFinishAt(); }); return new ArrayCollection($events); } public function addEvent(Event $event): self { if (!$this->events->contains($event)) { $this->events[] = $event; $event->setProjects($this); } return $this; } public function removeEvent(Event $event): self { if ($this->events->removeElement($event)) { // set the owning side to null (unless already changed) if ($event->getProjects() === $this) { $event->setProjects(null); } } return $this; } }