Toevoeging van meer responses op messages

This commit is contained in:
Frank
2026-01-05 23:37:36 +01:00
parent 10c3dbc066
commit 8e3807e079
10 changed files with 340 additions and 22 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Game\Entity;
use App\Game\Enum\SessionStatus;
use App\Game\Repository\SessionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@@ -16,7 +18,7 @@ class Session
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Game::class)]
#[ORM\ManyToOne(targetEntity: Game::class, inversedBy: 'sessions')]
#[ORM\JoinColumn(nullable: false)]
private ?Game $game = null;
@@ -29,9 +31,17 @@ class Session
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $created = null;
#[ORM\OneToMany(mappedBy: 'session', targetEntity: Player::class)]
private Collection $players;
#[ORM\OneToMany(mappedBy: 'session', targetEntity: SessionSetting::class)]
private Collection $settings;
public function __construct()
{
$this->created = new \DateTime();
$this->players = new ArrayCollection();
$this->settings = new ArrayCollection();
}
public function getId(): ?int
@@ -86,4 +96,64 @@ class Session
return $this;
}
/**
* @return Collection<int, Player>
*/
public function getPlayers(): Collection
{
return $this->players;
}
public function addPlayer(Player $player): static
{
if (!$this->players->contains($player)) {
$this->players->add($player);
$player->setSession($this);
}
return $this;
}
public function removePlayer(Player $player): static
{
if ($this->players->removeElement($player)) {
// set the owning side to null (unless already changed)
if ($player->getSession() === $this) {
$player->setSession(null);
}
}
return $this;
}
/**
* @return Collection<int, SessionSetting>
*/
public function getSettings(): Collection
{
return $this->settings;
}
public function addSetting(SessionSetting $setting): static
{
if (!$this->settings->contains($setting)) {
$this->settings->add($setting);
$setting->setSession($this);
}
return $this;
}
public function removeSetting(SessionSetting $setting): static
{
if ($this->settings->removeElement($setting)) {
// set the owning side to null (unless already changed)
if ($setting->getSession() === $this) {
$setting->setSession(null);
}
}
return $this;
}
}