Merging Corridor and Room in Place

This commit is contained in:
Kouril42
2023-02-02 17:09:16 +01:00
parent ce2c643cc6
commit 250e186017
11 changed files with 142 additions and 323 deletions
+79 -13
View File
@@ -8,10 +8,10 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlaceRepository::class)]
#[ORM\MappedSuperclass]
#[ORM\InheritanceType("JOINED")]
#[ORM\DiscriminatorColumn(name: "type", type: "string")]
#[ORM\DiscriminatorMap(["room" => Room::class, "corridor" => Corridor::class])]
// #[ORM\MappedSuperclass]
// #[ORM\InheritanceType("JOINED")]
// #[ORM\DiscriminatorColumn(name: "type", type: "string")]
// #[ORM\DiscriminatorMap(["room" => Room::class, "corridor" => Corridor::class])]
class Place
{
#[ORM\Id]
@@ -19,19 +19,33 @@ class Place
#[ORM\Column(type: "integer")]
private $id;
#[ORM\Type]
#[ORM\Column(type: "string")]
// Either 'C'orridor , 'S'tairs , 'E'levator or 'R'oom
private $type;
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
private $names;
#[ORM\OneToMany(targetEntity: RoomUserName::class, mappedBy: "place")]
private $users;
#[ORM\ManyToMany(targetEntity: Floor::class, inversedBy: "places")]
private $floors;
#[ORM\ManyToMany(targetEntity: Place::class, inversedBy: "connectedPlaces")]
private $connection;
#[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "connection")]
private $connectedPlaces;
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
private $names;
public function __construct()
{
$this->connection = new ArrayCollection();
$this->connectedPlaces = new ArrayCollection();
$this->names = new ArrayCollection();
$this->users = new ArrayCollection();
$this->floors = new ArrayCollection();
}
public function getId(): ?int
@@ -39,10 +53,23 @@ class Place
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): bool
{
if ($type == 'C' or $type == 'S' or $type == 'E' or $type == 'R') {
$this->type = $type;
return true;
}
return false;
}
/**
* @return Collection<int, self>
*/
public function getName(): Collection
public function getNames(): Collection
{
return $this->names;
}
@@ -52,14 +79,57 @@ class Place
if (!$this->names->contains($name)) {
$this->names[] = $name;
}
return $this;
}
public function removeName(self $name): self
{
$this->names->removeElement($name);
return $this;
}
/**
* @return Collection<int, self>
*/
public function getRoomUsers(): Collection
{
return $this->users;
}
public function addRoomUser(self $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
return $this;
}
public function removeRoomUser(self $user): self
{
$this->users->removeElement($user);
return $this;
}
/**
* @return Collection<int, ThreeDObjectFile>
*/
public function getFloors(): Collection
{
return $this->floors;
}
public function addFloor(self $floor): self
{
if (!$this->floors->contains($floor)) {
$this->floors[] = $floor;
}
return $this;
}
public function removeFloor(self $floor): self
{
$this->floors->removeElement($floor);
return $this;
}
/**
@@ -75,14 +145,12 @@ class Place
if (!$this->connection->contains($connection)) {
$this->connection[] = $connection;
}
return $this;
}
public function removeConnection(self $connection): self
{
$this->connection->removeElement($connection);
return $this;
}
@@ -100,7 +168,6 @@ class Place
$this->connectedPlaces[] = $connectedPlace;
$connectedPlace->addConnection($this);
}
return $this;
}
@@ -109,7 +176,6 @@ class Place
if ($this->connectedPlaces->removeElement($connectedPlace)) {
$connectedPlace->removeConnection($this);
}
return $this;
}
}