Bladeren bron

fix doctrine schema (ongoing)

Olivier Massot 8 maanden geleden
bovenliggende
commit
b64565c9d9

+ 8 - 15
src/Entity/Billing/AbstractBillAccounting.php

@@ -20,6 +20,14 @@ use Doctrine\ORM\Mapping as ORM;
  * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table BillAccounting, et supprimer l'attribut discr.
  */
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'billaccounting' => BillAccounting::class,
+        'bill' => Bill::class,
+        'billcredit' => BillCredit::class,
+    ]
+)]
 abstract class AbstractBillAccounting
 {
     #[ORM\Id]
@@ -27,9 +35,6 @@ abstract class AbstractBillAccounting
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr;
-
     #[ORM\ManyToOne(targetEntity: Organization::class)]
     #[ORM\JoinColumn(nullable: true)]
     protected Organization $organization;
@@ -114,18 +119,6 @@ abstract class AbstractBillAccounting
         return $this->id;
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getOrganization(): ?Organization
     {
         return $this->organization;

+ 0 - 8
src/Entity/Billing/BillAccounting.php

@@ -12,14 +12,6 @@ use Doctrine\ORM\Mapping as ORM;
 // #[Auditable]
 #[ORM\Entity]
 #[ORM\InheritanceType('SINGLE_TABLE')]
-#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
-#[ORM\DiscriminatorMap(
-    [
-        'billaccounting' => BillAccounting::class,
-        'bill' => Bill::class,
-        'billcredit' => BillCredit::class,
-    ]
-)]
 class BillAccounting extends AbstractBillAccounting
 {
 }

+ 0 - 79
src/Entity/Booking/AbstractBooking.php

@@ -61,22 +61,6 @@ abstract class AbstractBooking
     #[ORM\Column(unique: true)]
     protected string $uuid;
 
-    #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'practicalCourses', cascade: [], orphanRemoval: false)]
-    protected Collection $organizer;
-
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    protected Collection $equipments;
-
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'bookings', cascade: ['persist'], orphanRemoval: false)]
-    protected Collection $tags;
-
-    public function __construct()
-    {
-        $this->organizer = new ArrayCollection();
-        $this->equipments = new ArrayCollection();
-        $this->tags = new ArrayCollection();
-    }
-
     public function getId(): ?int
     {
         return $this->id;
@@ -141,67 +125,4 @@ abstract class AbstractBooking
 
         return $this;
     }
-
-    public function getOrganizer(): Collection
-    {
-        return $this->organizer;
-    }
-
-    public function addOrganizer(Access $organizer): self
-    {
-        if (!$this->organizer->contains($organizer)) {
-            $this->organizer[] = $organizer;
-        }
-
-        return $this;
-    }
-
-    public function removeOrganizer(Access $organizer): self
-    {
-        $this->organizer->removeElement($organizer);
-
-        return $this;
-    }
-
-    public function getEquipments(): Collection
-    {
-        return $this->equipments;
-    }
-
-    public function addEquipment(Equipment $equipment): self
-    {
-        if (!$this->equipments->contains($equipment)) {
-            $this->equipments[] = $equipment;
-        }
-
-        return $this;
-    }
-
-    public function removeEquipment(Equipment $equipment): self
-    {
-        $this->equipments->removeElement($equipment);
-
-        return $this;
-    }
-
-    public function getTags(): Collection
-    {
-        return $this->tags;
-    }
-
-    public function addTag(Tagg $tag): self
-    {
-        if (!$this->tags->contains($tag)) {
-            $this->tags[] = $tag;
-        }
-
-        return $this;
-    }
-
-    public function removeTag(Tagg $tag): self
-    {
-        $this->tags->removeElement($tag);
-
-        return $this;
-    }
 }

+ 0 - 3
src/Entity/Booking/Event.php

@@ -30,9 +30,6 @@ use Symfony\Component\Validator\Constraints as Assert;
 #[ORM\Table(name: 'Booking')]
 class Event extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr = 'event';
-
     #[ORM\ManyToOne(inversedBy: 'events')]
     #[ORM\JoinColumn(nullable: false)]
     protected Organization $organization;

+ 0 - 32
src/Entity/Core/AbstractControl.php

@@ -32,14 +32,6 @@ abstract class AbstractControl
     #[ORM\JoinColumn(nullable: true)]
     protected ?Access $accompanist = null;
 
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'controls', cascade: ['persist'], orphanRemoval: false)]
-    protected Collection $tags;
-
-    public function __construct()
-    {
-        $this->tags = new ArrayCollection();
-    }
-
     public function getId(): ?int
     {
         return $this->id;
@@ -56,28 +48,4 @@ abstract class AbstractControl
 
         return $this;
     }
-
-    public function getTags(): Collection
-    {
-        return $this->tags;
-    }
-
-    public function addTag(Tagg $tag): self
-    {
-        if (!$this->tags->contains($tag)) {
-            $this->tags[] = $tag;
-            $tag->addControl($this);
-        }
-
-        return $this;
-    }
-
-    public function removeTag(Tagg $tag): self
-    {
-        if ($this->tags->removeElement($tag)) {
-            $tag->addControl($this);
-        }
-
-        return $this;
-    }
 }

+ 1 - 4
src/Entity/Core/ContactPoint.php

@@ -83,11 +83,8 @@ class ContactPoint
     #[ORM\InverseJoinColumn(name: 'person_id', referencedColumnName: 'id')]
     private Collection $person;
 
-    /** @var Collection<int, Place> */
+    /** @var Collection<int, AbstractPlace> */
     #[ORM\ManyToMany(targetEntity: AbstractPlace::class, mappedBy: 'contactpoint')]
-    #[ORM\JoinTable(name: 'place_contactpoint')]
-    #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
-    #[ORM\InverseJoinColumn(name: 'place_id', referencedColumnName: 'id')]
     private Collection $place;
 
     #[Pure]

+ 1 - 7
src/Entity/Message/Email.php

@@ -6,6 +6,7 @@ namespace App\Entity\Message;
 
 use ApiPlatform\Metadata\ApiResource;
 use App\Entity\Access\Access;
+use App\Entity\Core\File;
 use App\Entity\Core\Tagg;
 // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use App\Entity\Education\EducationStudent;
@@ -42,13 +43,6 @@ class Email extends AbstractMessage
     #[ORM\JoinColumn(nullable: true)]
     private ?Mail $mailAttached = null;
 
-    /** @var Collection<int, File> */
-    #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
-    #[ORM\JoinTable(name: 'messages_files')]
-    #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id', onDelete: 'cascade')]
-    #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
-    protected Collection $files;
-
     /** @var Collection<int, Tagg> */
     #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'emails', cascade: ['persist'])]
     #[ORM\JoinTable(name: 'tag_message')]

+ 10 - 15
src/Entity/Place/AbstractPlace.php

@@ -24,6 +24,13 @@ use Doctrine\ORM\Mapping as ORM;
  * Classe ... qui ...
  */
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'place_system' => PlaceSystem::class,
+        'place' => Place::class,
+    ]
+)]
 abstract class AbstractPlace
 {
     #[ORM\Id]
@@ -31,9 +38,6 @@ abstract class AbstractPlace
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr;
-
     #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'places')]
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     private AddressPostal $addressPostal;
@@ -51,6 +55,9 @@ abstract class AbstractPlace
     private Organization $organization;
 
     #[ORM\ManyToMany(targetEntity: ContactPoint::class, inversedBy: 'place', cascade: ['persist'])]
+    #[ORM\JoinTable(name: 'place_contactpoint')]
+    #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
+    #[ORM\InverseJoinColumn(name: 'place_id', referencedColumnName: 'id')]
     private Collection $contactpoint;
 
     #[ORM\OneToMany(mappedBy: 'place', targetEntity: Room::class, cascade: ['persist'], orphanRemoval: true)]
@@ -100,18 +107,6 @@ abstract class AbstractPlace
         return $this->id;
     }
 
-    public function getDiscr(): string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getAddressPostal(): ?AddressPostal
     {
         return $this->addressPostal;

+ 0 - 2
src/Entity/Place/PlaceSystem.php

@@ -17,6 +17,4 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Place')]
 class PlaceSystem extends AbstractPlace
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr = 'place_system';
 }