Add PlaceType enum and modifiy initialData syntax (debug)

This commit is contained in:
2023-03-02 23:17:24 +01:00
parent b958948e35
commit 7621190896
3 changed files with 37 additions and 32 deletions
+13 -9
View File
@@ -7,6 +7,14 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
enum PlaceType: string {
case Room = 'R';
case Corridor = 'C';
case Stairs = 'S';
case Lift = 'L';
case Toilets = 'T';
}
#[ORM\Entity(repositoryClass: PlaceRepository::class)]
class Place
{
@@ -15,8 +23,7 @@ class Place
#[ORM\Column(type: "integer")]
private $id;
#[ORM\Column(type: "string")]
// Either 'C'orridor , 'S'tairs , 'L'ift or 'R'oom
#[ORM\Column(type: "string", enumType: PlaceType::class)]
private $type;
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
@@ -58,17 +65,14 @@ class Place
return $this->id;
}
public function getType(): ?string
public function getType(): ?PlaceType
{
return $this->type;
}
public function setType(string $type): bool
public function setType(PlaceType $type): bool
{
if ($type == 'C' or $type == 'S' or $type == 'L' or $type == 'R') {
$this->type = $type;
return true;
}
return false;
$this->type = $type;
return true;
}
/**