*/ #[ORM\OneToMany(targetEntity: Session::class, mappedBy: 'joueur')] private Collection $sessions; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Territoire::class, mappedBy: 'joueurs')] private Collection $territoires; #[ORM\OneToOne(mappedBy: 'joueur', cascade: ['persist', 'remove'])] private ?User $owner = null; public function __construct(string $uuid) { $this->id = $uuid; $this->sessions = new ArrayCollection(); $this->territoires = new ArrayCollection(); } public function getId(): string { return $this->id; } public function getPseudo(): ?string { return $this->pseudo; } public function setPseudo(string $pseudo): static { $this->pseudo = $pseudo; return $this; } /** * @return Collection */ public function getSessions(): Collection { return $this->sessions; } public function addSession(Session $session): static { if (!$this->sessions->contains($session)) { $this->sessions->add($session); $session->setJoueur($this); } return $this; } public function removeSession(Session $session): static { if ($this->sessions->removeElement($session)) { // set the owning side to null (unless already changed) if ($session->getJoueur() === $this) { $session->setJoueur(null); } } return $this; } /** * @return Collection */ public function getTerritoires(): Collection { return $this->territoires; } public function addTerritoire(Territoire $territoire): static { if (!$this->territoires->contains($territoire)) { $this->territoires->add($territoire); $territoire->addJoueur($this); } return $this; } public function removeTerritoire(Territoire $territoire): static { if ($this->territoires->removeElement($territoire)) { $territoire->removeJoueur($this); } return $this; } public function getOwner(): ?User { return $this->owner; } public function setOwner(?User $owner): static { // unset the owning side of the relation if necessary if ($owner === null && $this->owner !== null) { $this->owner->setJoueur(null); } // set the owning side of the relation if necessary if ($owner !== null && $owner->getJoueur() !== $this) { $owner->setJoueur($this); } $this->owner = $owner; return $this; } }