Toevoeging van meer responses op messages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user