Fix de quelques erreurs Doctrine et ajout des noms des Places

This commit is contained in:
Mysaa 2023-01-31 14:54:17 +01:00
parent 911a22cbac
commit 87518f9ebc
Signed by: Mysaa
GPG Key ID: 7054D5D6A90F084F
7 changed files with 134 additions and 5 deletions

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230131135243 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE place_name_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE place_name (id INT NOT NULL, room_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_94960EEA54177093 ON place_name (room_id)');
$this->addSql('ALTER TABLE place_name ADD CONSTRAINT FK_94960EEA54177093 FOREIGN KEY (room_id) REFERENCES place (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE place_name_id_seq CASCADE');
$this->addSql('ALTER TABLE place_name DROP CONSTRAINT FK_94960EEA54177093');
$this->addSql('DROP TABLE place_name');
}
}

View File

@ -3,6 +3,7 @@
namespace App\Entity;
use App\Repository\CorridorRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CorridorRepository::class)]
class Corridor extends Place

View File

@ -16,7 +16,7 @@ class Cylinder
#[ORM\Column(type: "float")]
private $height;
#[ORM\OneToOne(targetEntity: PlaneSurface::class, cascade: {"persist", "remove"})]
#[ORM\OneToOne(targetEntity: PlaneSurface::class, cascade: ["persist", "remove"])]
#[ORM\JoinColumn(nullable: false)]
private $cylinderbase;

View File

@ -8,9 +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","corridor": "Corridor"})]
#[ORM\DiscriminatorMap(["room" => Room::class, "corridor" => Corridor::class])]
class Place
{
#[ORM\Id]
@ -24,6 +25,9 @@ class Place
#[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();

87
src/Entity/PlaceName.php Normal file
View File

@ -0,0 +1,87 @@
<?php
namespace App\Entity;
use App\Repository\PolyhedronRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlaceNamenRepository::class)]
class PlaceName
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
private $id;
#[ORM\Column(type: "string")]
private $name;
#[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "names")]
private $room;
public function __construct()
{
$this->polyhedronface = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, PlaneSurface>
*/
public function getPolyhedronface(): Collection
{
return $this->polyhedronface;
}
public function addPolyhedronface(PlaneSurface $polyhedronface): self
{
if (!$this->polyhedronface->contains($polyhedronface)) {
$this->polyhedronface[] = $polyhedronface;
$polyhedronface->setPolyhedron($this);
}
return $this;
}
public function removePolyhedronface(PlaneSurface $polyhedronface): self
{
if ($this->polyhedronface->removeElement($polyhedronface)) {
// set the owning side to null (unless already changed)
if ($polyhedronface->getPolyhedron() === $this) {
$polyhedronface->setPolyhedron(null);
}
}
return $this;
}
public function getRoom(): ?Room
{
return $this->room;
}
public function setRoom(?Room $room): self
{
$this->room = $room;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
}

View File

@ -13,10 +13,10 @@ class ThreeDObjectFile
#[ORM\Column(type: "integer")]
private $id;
#[@ORM\Column(type: "string", length: 255)]
#[ORM\Column(type: "string", length: 255)]
private $filename;
#[@ORM\ManyToOne(targetEntity: Room::class, inversedBy: "ComplexRepresentation")]
#[ORM\ManyToOne(targetEntity: Room::class, inversedBy: "ComplexRepresentation")]
private $room;
public function getId(): ?int