mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
Add PlaceType enum and modifiy initialData syntax (debug)
This commit is contained in:
+13
-9
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user