浏览代码

review schema of entities with discr

Olivier Massot 8 月之前
父节点
当前提交
e2cf1bc1eb

+ 0 - 1
src/Entity/Access/Access.php

@@ -18,7 +18,6 @@ use App\Entity\Billing\Bill;
 use App\Entity\Billing\BillCredit;
 use App\Entity\Billing\BillLine;
 use App\Entity\Billing\EducationalProjectPayer;
-use App\Entity\Booking\AbstractBooking;
 use App\Entity\Booking\Attendance;
 use App\Entity\Booking\AttendanceBooking;
 use App\Entity\Booking\CalendarSynchro;

+ 2 - 2
src/Entity/Billing/AbstractBillingIntangible.php

@@ -19,8 +19,8 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\InheritanceType('SINGLE_TABLE')]
 #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
 #[ORM\DiscriminatorMap([
-    'access' => 'AccessIntangible',
-    'educationalproject' => 'EducationalProjectIntangible',
+    'access' => AccessIntangible::class,
+    'educationalproject' => EducationalProjectIntangible::class,
 ])]
 abstract class AbstractBillingIntangible
 {

+ 35 - 9
src/Entity/Booking/AbstractBooking.php

@@ -6,10 +6,14 @@ namespace App\Entity\Booking;
 
 use App\Attribute\ActivityYearConstraintAware;
 use App\Attribute\OrganizationDefaultValue;
+use App\Entity\Access\Access;
 use App\Entity\Core\Tagg;
+use App\Entity\Product\Equipment;
 use App\Entity\Traits\ActivityYearTrait;
 use App\Enum\Booking\VisibilityEnum;
+use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Cache\CollectionCacheEntry;
 use Doctrine\ORM\Mapping as ORM;
 
 /**
@@ -41,20 +45,27 @@ abstract class AbstractBooking
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr;
-
     #[ORM\Column]
     protected string $name;
 
+    /** @var Collection<int, Access> */
+    #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'educationalProjectOrganizers')]
+    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
+    #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
+    protected Collection $organizer;
+
     #[ORM\Column(type: 'datetime', nullable: true)]
     protected ?\DateTimeInterface $datetimeStart = null;
 
     #[ORM\Column(type: 'datetime', nullable: true)]
     protected ?\DateTimeInterface $datetimeEnd = null;
 
-    #[ORM\Column(length: 50, nullable: false, enumType: VisibilityEnum::class)]
-    protected VisibilityEnum $visibility;
+    /** @var Collection<int, Equipment> */
+    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
+    #[ORM\JoinTable(name: 'booking_equipment')]
+    #[ORM\JoinColumn(name: 'booking_id')]
+    #[ORM\InverseJoinColumn(name: 'equipment_id')]
+    protected Collection $equipments;
 
     #[ORM\Column(unique: true)]
     protected string $uuid;
@@ -66,6 +77,14 @@ abstract class AbstractBooking
     #[ORM\InverseJoinColumn(name: 'tag_id')]
     protected Collection $tags;
 
+    public function __construct()
+    {
+        $this->eventRecur = new ArrayCollection();
+        $this->organizer = new ArrayCollection();
+        $this->equipments = new ArrayCollection();
+        $this->tags = new ArrayCollection();
+    }
+
     public function getId(): ?int
     {
         return $this->id;
@@ -107,14 +126,21 @@ abstract class AbstractBooking
         return $this->datetimeEnd;
     }
 
-    public function getVisibility(): ?VisibilityEnum
+    public function getEquipments(): Collection
     {
-        return $this->visibility;
+        return $this->equipments;
+    }
+
+    public function addEquipment(Equipment $equipment): self
+    {
+        $this->equipments[] = $equipment;
+
+        return $this;
     }
 
-    public function setVisibility(?VisibilityEnum $visibility): self
+    public function removeEquipment(Equipment $equipment): self
     {
-        $this->visibility = $visibility;
+        $this->equipments->removeElement($equipment);
 
         return $this;
     }

+ 1 - 94
src/Entity/Booking/Course.php

@@ -54,13 +54,6 @@ class Course extends AbstractBooking
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     protected ?Room $room = null;
 
-    /** @var Collection<int, Access> */
-    #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'practicalCourses')]
-    #[ORM\JoinTable(name: 'booking_organizer')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
-    protected Collection $organizer;
-
     #[ORM\ManyToOne(inversedBy: 'courses')]
     #[ORM\JoinColumn(nullable: false)]
     protected Organization $organization;
@@ -84,25 +77,11 @@ class Course extends AbstractBooking
     #[ORM\OneToMany(targetEntity: Work::class, mappedBy: 'course', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $work;
 
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id', referencedColumnName: 'id')]
-    protected Collection $equipments;
-
     /** @var Collection<int, AttendanceBooking> */
     #[ORM\OneToMany(targetEntity: AttendanceBooking::class, mappedBy: 'course', cascade: ['persist'], orphanRemoval: true)]
     #[ORM\JoinColumn(nullable: false)]
     protected Collection $attendanceBooking;
 
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'courses', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_booking')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected Collection $tags;
-
     /** @var Collection<int, EducationStudentWish> */
     #[ORM\OneToMany(targetEntity: EducationStudentWish::class, mappedBy: 'course', cascade: [], orphanRemoval: false)]
     protected Collection $educationStudentWishes;
@@ -117,8 +96,8 @@ class Course extends AbstractBooking
         $this->work = new ArrayCollection();
         $this->equipments = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
-        $this->tags = new ArrayCollection();
         $this->educationStudentWishes = new ArrayCollection();
+        parent::__construct();
     }
 
     /**
@@ -217,30 +196,6 @@ class Course extends AbstractBooking
         return $this;
     }
 
-    /**
-     * @return Collection<int, Access>
-     */
-    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 getOrganization(): ?Organization
     {
         return $this->organization;
@@ -343,30 +298,6 @@ class Course extends AbstractBooking
         return $this;
     }
 
-    /**
-     * @return Collection<int, Equipment>
-     */
-    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;
-    }
-
     /**
      * @return Collection<int, AttendanceBooking>
      */
@@ -397,30 +328,6 @@ class Course extends AbstractBooking
         return $this;
     }
 
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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;
-    }
-
     public function getEducationStudentWishes(): Collection
     {
         return $this->educationStudentWishes;

+ 5 - 73
src/Entity/Booking/EducationalProject.php

@@ -35,7 +35,7 @@ class EducationalProject extends AbstractBooking
     protected Collection $eventRecur;
 
     /** @var Collection<int, EducationalProject> */
-    #[ORM\OneToMany(mappedBy: 'parent', targetEntity: EducationalProject::class, orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EducationalProject::class, mappedBy: 'parent', orphanRemoval: true)]
     protected Collection $timeline;
 
     #[ORM\ManyToOne(inversedBy: 'timeline')]
@@ -67,15 +67,15 @@ class EducationalProject extends AbstractBooking
     protected Collection $files;
 
     /** @var Collection<int, EducationalProjectIntangible> */
-    #[ORM\OneToMany(mappedBy: 'educationalProject', targetEntity: EducationalProjectIntangible::class, cascade: ['persist'], orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EducationalProjectIntangible::class, mappedBy: 'educationalProject', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $educationalProjectIntangibles;
 
     /** @var Collection<int, EducationalProjectPayer> */
-    #[ORM\OneToMany(mappedBy: 'educationalProjectReceiver', targetEntity: EducationalProjectPayer::class, cascade: ['persist'], orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EducationalProjectPayer::class, mappedBy: 'educationalProjectReceiver', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $billingReceivers;
 
     /** @var Collection<int, BillLine> */
-    #[ORM\OneToMany(mappedBy: 'educationalProject', targetEntity: BillLine::class, orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: BillLine::class, mappedBy: 'educationalProject', orphanRemoval: true)]
     protected Collection $billLines;
 
     /** @var Collection<int, AttendanceBooking> */
@@ -91,29 +91,9 @@ class EducationalProject extends AbstractBooking
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     protected ?Room $room = null;
 
-    /** @var Collection<int, Access> */
-    #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'educationalProjectOrganizers')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
-    protected Collection $organizer;
-
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'educationalProjects', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_booking')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected Collection $tags;
-
     #[ORM\OneToOne(targetEntity: EducationalProjectAge::class, cascade: ['persist'])]
     protected ?EducationalProjectAge $ageDistribution;
 
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id')]
-    protected Collection $equipments;
-
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
@@ -125,8 +105,8 @@ class EducationalProject extends AbstractBooking
         $this->billLines = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
         $this->organizer = new ArrayCollection();
-        $this->tags = new ArrayCollection();
         $this->equipments = new ArrayCollection();
+        parent::__construct();
     }
 
     /**
@@ -465,30 +445,6 @@ class EducationalProject extends AbstractBooking
         return $this;
     }
 
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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;
-    }
-
     public function getAgeDistribution(): ?EducationalProjectAge
     {
         return $this->ageDistribution;
@@ -500,28 +456,4 @@ class EducationalProject extends AbstractBooking
 
         return $this;
     }
-
-    public function getEquipments(): Collection
-    {
-        return $this->equipments;
-    }
-
-    public function addEquipment(Equipment $equipment): self
-    {
-        if (!$this->equipments->contains($equipment)) {
-            $this->equipments[] = $equipment;
-            //            $equipment->addXXX($this);
-        }
-
-        return $this;
-    }
-
-    public function removeEquipment(Equipment $equipment): self
-    {
-        if ($this->equipments->removeElement($equipment)) {
-            //            $equipment->removeXXXX($this);
-        }
-
-        return $this;
-    }
 }

+ 1 - 94
src/Entity/Booking/Event.php

@@ -91,27 +91,6 @@ class Event extends AbstractBooking
     #[ORM\JoinColumn(nullable: false)]
     protected Collection $attendanceBooking;
 
-    /** @var Collection<int, Access> */
-    #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'eventOrganizers')]
-    #[ORM\JoinTable(name: 'booking_organizer')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
-    protected Collection $organizer;
-
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id')]
-    protected Collection $equipments;
-
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'events', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_booking')]
-    #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected Collection $tags;
-
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
@@ -122,8 +101,8 @@ class Event extends AbstractBooking
         $this->files = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
         $this->organizer = new ArrayCollection();
-        $this->tags = new ArrayCollection();
         $this->equipments = new ArrayCollection();
+        parent::__construct();
     }
 
     public function getOrganization(): ?Organization
@@ -407,76 +386,4 @@ class Event extends AbstractBooking
 
         return $this;
     }
-
-    /**
-     * @return Collection<int, Access>
-     */
-    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;
-    }
-
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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;
-    }
-
-    public function getEquipments(): Collection
-    {
-        return $this->equipments;
-    }
-
-    public function addEquipment(Equipment $equipment): self
-    {
-        if (!$this->equipments->contains($equipment)) {
-            $this->equipments[] = $equipment;
-            //            $equipment->addXXX($this);
-        }
-
-        return $this;
-    }
-
-    public function removeEquipment(Equipment $equipment): self
-    {
-        if ($this->equipments->removeElement($equipment)) {
-            //            $equipment->removeXXXX($this);
-        }
-
-        return $this;
-    }
 }

+ 1 - 10
src/Entity/Booking/Examen.php

@@ -73,22 +73,13 @@ class Examen extends AbstractBooking
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     protected ?Room $room = null;
 
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id')]
-    protected Collection $equipments;
-
     public function __construct()
     {
-        $this->eventRecur = new ArrayCollection();
         $this->timeline = new ArrayCollection();
         $this->educationCurriculum = new ArrayCollection();
         $this->convocation = new ArrayCollection();
         $this->attendanceBooking = new ArrayCollection();
-        $this->tags = new ArrayCollection();
-        $this->equipments = new ArrayCollection();
+        parent::__construct();
     }
 
     public function getOrganization(): ?Organization

+ 2 - 58
src/Entity/Booking/OrganizationHoliday.php

@@ -26,24 +26,16 @@ class OrganizationHoliday extends AbstractBooking
 {
     /** @var Collection<int, OrganizationHolidayRecur> */
     #[ORM\OneToMany(targetEntity: OrganizationHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
-    private Collection $eventRecur;
+    protected Collection $eventRecur;
 
     #[ORM\ManyToOne(inversedBy: 'holidays')]
     #[ORM\JoinColumn(nullable: false)]
     private Organization $organization;
 
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id')]
-    protected Collection $equipments;
-
     public function __construct()
     {
         $this->eventRecur = new ArrayCollection();
-        $this->equipments = new ArrayCollection();
-        $this->tags = new ArrayCollection();
+        parent::__construct();
     }
 
     /**
@@ -87,52 +79,4 @@ class OrganizationHoliday extends AbstractBooking
 
         return $this;
     }
-
-    public function getEquipments(): Collection
-    {
-        return $this->equipments;
-    }
-
-    public function addEquipment(Equipment $equipment): self
-    {
-        if (!$this->equipments->contains($equipment)) {
-            $this->equipments[] = $equipment;
-            //            $equipment->addXXX($this);
-        }
-
-        return $this;
-    }
-
-    public function removeEquipment(Equipment $equipment): self
-    {
-        if ($this->equipments->removeElement($equipment)) {
-            //            $equipment->removeXXXX($this);
-        }
-
-        return $this;
-    }
-
-    public function getTags(): Collection
-    {
-        return $this->tags;
-    }
-
-    public function addTag(Tagg $tag): self
-    {
-        if (!$this->tags->contains($tag)) {
-            $this->tags[] = $tag;
-            $tag->addBooking($this);
-        }
-
-        return $this;
-    }
-
-    public function removeTag(Tagg $tag): self
-    {
-        if ($this->tags->removeElement($tag)) {
-            $tag->removeBooking($this);
-        }
-
-        return $this;
-    }
 }

+ 9 - 58
src/Entity/Booking/PersonHoliday.php

@@ -24,10 +24,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class PersonHoliday extends AbstractBooking
 {
-    /** @var Collection<int, PersonHolidayRecur> */
-    #[ORM\OneToMany(targetEntity: PersonHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
-    protected Collection $eventRecur;
-
     #[ORM\ManyToOne(inversedBy: 'holidays')]
     private ?Access $access = null;
 
@@ -35,49 +31,9 @@ class PersonHoliday extends AbstractBooking
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
     protected Organization $organization;
 
-    /** @var Collection<int, Equipment> */
-    #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
-    #[ORM\JoinTable(name: 'booking_equipment')]
-    #[ORM\JoinColumn(name: 'booking_id')]
-    #[ORM\InverseJoinColumn(name: 'equipment_id')]
-    protected Collection $equipments;
-
-    public function __construct()
-    {
-        $this->eventRecur = new ArrayCollection();
-        $this->equipments = new ArrayCollection();
-        $this->tags = new ArrayCollection();
-    }
-
-    /**
-     * @return Collection<int, PersonHolidayRecur>
-     */
-    public function getEventRecur(): Collection
-    {
-        return $this->eventRecur;
-    }
-
-    public function addEventRecur(PersonHolidayRecur $eventRecur): self
-    {
-        if (!$this->eventRecur->contains($eventRecur)) {
-            $this->eventRecur[] = $eventRecur;
-            $eventRecur->setEvent($this);
-        }
-
-        return $this;
-    }
-
-    public function removeEventRecur(PersonHolidayRecur $eventRecur): self
-    {
-        if ($this->eventRecur->removeElement($eventRecur)) {
-            // set the owning side to null (unless already changed)
-            if ($eventRecur->getEvent() === $this) {
-                $eventRecur->setEvent(null);
-            }
-        }
-
-        return $this;
-    }
+    /** @var Collection<int, PersonHolidayRecur> */
+    #[ORM\OneToMany(targetEntity: PersonHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
+    protected Collection $eventRecur;
 
     public function getAccess(): ?Access
     {
@@ -103,26 +59,21 @@ class PersonHoliday extends AbstractBooking
         return $this;
     }
 
-    public function getEquipments(): Collection
+    public function getOrganizer(): Collection
     {
-        return $this->equipments;
+        return $this->organizer;
     }
 
-    public function addEquipment(Equipment $equipment): self
+    public function addOrganizer(Access $organizer): self
     {
-        if (!$this->equipments->contains($equipment)) {
-            $this->equipments[] = $equipment;
-            //            $equipment->addXXXX($this); // TODO: compléter
-        }
+        $this->organizer[] = $organizer;
 
         return $this;
     }
 
-    public function removeEquipment(Equipment $equipment): self
+    public function removeOrganizer(Access $organizer): self
     {
-        if ($this->equipments->removeElement($equipment)) {
-            //            $equipment->removeXXXX($this); // TODO: compléter
-        }
+        $this->organizer->removeElement($organizer);
 
         return $this;
     }

+ 2 - 34
src/Entity/Core/AbstractInformation.php

@@ -28,8 +28,8 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
 #[ORM\InheritanceType('SINGLE_TABLE')]
 #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
 #[ORM\DiscriminatorMap([
-    'notification' => 'Notification',
-    'tips' => 'Tips',
+    'notification' => Notification::class,
+    'tips' => Tips::class,
 ])]
 class AbstractInformation
 {
@@ -38,14 +38,6 @@ class AbstractInformation
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
-    #[ORM\ManyToOne(inversedBy: 'notifications')]
-    #[ORM\JoinColumn(nullable: false)]
-    protected Access $recipientAccess;
-
-    #[ORM\ManyToOne(inversedBy: 'notifications')]
-    #[ORM\JoinColumn(nullable: false)]
-    protected Organization $recipientOrganization;
-
     #[ORM\Column(length: 40, nullable: true)]
     protected ?string $name = null;
 
@@ -95,30 +87,6 @@ class AbstractInformation
         return $this->name;
     }
 
-    public function setRecipientAccess(?Access $recipientAccess): self
-    {
-        $this->recipientAccess = $recipientAccess;
-
-        return $this;
-    }
-
-    public function getRecipientAccess(): ?Access
-    {
-        return $this->recipientAccess;
-    }
-
-    public function getRecipientOrganization(): ?Organization
-    {
-        return $this->recipientOrganization;
-    }
-
-    public function setRecipientOrganization(?Organization $recipientOrganization): self
-    {
-        $this->recipientOrganization = $recipientOrganization;
-
-        return $this;
-    }
-
     public function getCreateDate(): ?\DateTimeInterface
     {
         return $this->createDate;

+ 33 - 0
src/Entity/Core/Notification.php

@@ -7,6 +7,8 @@ namespace App\Entity\Core;
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use App\Entity\Access\Access;
+use App\Entity\Organization\Organization;
 use App\Repository\Core\NotificationRepository;
 // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use Doctrine\ORM\Mapping as ORM;
@@ -34,4 +36,35 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity(repositoryClass: NotificationRepository::class)]
 class Notification extends AbstractInformation
 {
+    #[ORM\ManyToOne(inversedBy: 'notifications')]
+    #[ORM\JoinColumn(nullable: false)]
+    protected Access $recipientAccess;
+
+    #[ORM\ManyToOne(inversedBy: 'notifications')]
+    #[ORM\JoinColumn(nullable: false)]
+    protected Organization $recipientOrganization;
+
+    public function setRecipientAccess(?Access $recipientAccess): self
+    {
+        $this->recipientAccess = $recipientAccess;
+
+        return $this;
+    }
+
+    public function getRecipientAccess(): ?Access
+    {
+        return $this->recipientAccess;
+    }
+
+    public function getRecipientOrganization(): ?Organization
+    {
+        return $this->recipientOrganization;
+    }
+
+    public function setRecipientOrganization(?Organization $recipientOrganization): self
+    {
+        $this->recipientOrganization = $recipientOrganization;
+
+        return $this;
+    }
 }

+ 50 - 0
src/Entity/Message/AbstractMessage.php

@@ -5,13 +5,16 @@ declare(strict_types=1);
 namespace App\Entity\Message;
 
 use App\Attribute\OrganizationDefaultValue;
+use App\Entity\Access\Access;
 use App\Entity\Core\File;
+use App\Entity\Core\Tagg;
 use App\Entity\Organization\Organization;
 use App\Enum\Message\MessageStatusEnum;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 use Ramsey\Uuid\Doctrine\UuidGenerator;
+use Ramsey\Uuid\Uuid;
 use Ramsey\Uuid\UuidInterface;
 
 /**
@@ -45,6 +48,10 @@ abstract class AbstractMessage
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
+    #[ORM\ManyToOne(inversedBy: 'emails')]
+    #[ORM\JoinColumn(nullable: true)]
+    private ?Access $author = null;
+
     #[ORM\ManyToOne]
     #[ORM\JoinColumn(nullable: true)]
     protected ?Organization $organization = null;
@@ -73,8 +80,18 @@ abstract class AbstractMessage
     #[ORM\OneToMany(targetEntity: ReportMessage::class, mappedBy: 'message', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $reportMessage;
 
+    /** @var Collection<int, Tagg> */
+    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'messages', cascade: ['persist'])]
+    #[ORM\JoinTable(name: 'tag_message')]
+    #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id', onDelete: 'cascade')]
+    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id', onDelete: 'cascade')]
+    protected Collection $tags;
+
     public function __construct()
     {
+        $this->uuid = Uuid::uuid4();
+        $this->files = new ArrayCollection();
+        $this->tags = new ArrayCollection();
         $this->reportMessage = new ArrayCollection();
     }
 
@@ -88,6 +105,18 @@ abstract class AbstractMessage
         return $this->uuid;
     }
 
+    public function getAuthor(): ?Access
+    {
+        return $this->author;
+    }
+
+    public function setAuthor(?Access $author): self
+    {
+        $this->author = $author;
+
+        return $this;
+    }
+
     public function setOrganization(Organization $organization): self
     {
         $this->organization = $organization;
@@ -198,4 +227,25 @@ abstract class AbstractMessage
 
         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 - 50
src/Entity/Message/Email.php

@@ -27,10 +27,6 @@ class Email extends AbstractMessage
     #[ORM\Column(type: 'boolean', options: ['default' => false])]
     private bool $isSystem = false;
 
-    #[ORM\ManyToOne(inversedBy: 'emails')]
-    #[ORM\JoinColumn(nullable: true)]
-    private ?Access $author = null;
-
     /** @var Collection<int, ReportEmail> */
     #[ORM\OneToMany(targetEntity: ReportEmail::class, mappedBy: 'email', cascade: ['persist'], orphanRemoval: true)]
     #[ORM\JoinColumn(onDelete: 'cascade')]
@@ -40,19 +36,9 @@ class Email extends AbstractMessage
     #[ORM\JoinColumn(nullable: true)]
     private ?Mail $mailAttached = null;
 
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'emails', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_message')]
-    #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id', onDelete: 'cascade')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id', onDelete: 'cascade')]
-    protected Collection $tags;
-
     public function __construct()
     {
-        $this->uuid = Uuid::uuid4();
         $this->reports = new ArrayCollection();
-        $this->files = new ArrayCollection();
-        $this->tags = new ArrayCollection();
         parent::__construct();
     }
 
@@ -68,18 +54,6 @@ class Email extends AbstractMessage
         return $this->isSystem;
     }
 
-    public function getAuthor(): ?Access
-    {
-        return $this->author;
-    }
-
-    public function setAuthor(?Access $author): self
-    {
-        $this->author = $author;
-
-        return $this;
-    }
-
     /**
      * @return Collection<int, ReportEmail>
      */
@@ -121,28 +95,4 @@ class Email extends AbstractMessage
 
         return $this;
     }
-
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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 - 54
src/Entity/Message/Mail.php

@@ -24,58 +24,4 @@ use Ramsey\Uuid\Uuid;
 #[ORM\Entity]
 class Mail extends AbstractMessage
 {
-    #[ORM\ManyToOne(inversedBy: 'mails')]
-    #[ORM\JoinColumn(nullable: true)]
-    private ?Access $author = null;
-
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'mails', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_message')]
-    #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected Collection $tags;
-
-    public function __construct()
-    {
-        $this->uuid = Uuid::uuid4();
-        $this->files = new ArrayCollection();
-        $this->tags = new ArrayCollection();
-        parent::__construct();
-    }
-
-    public function getAuthor(): ?Access
-    {
-        return $this->author;
-    }
-
-    public function setAuthor(?Access $author): self
-    {
-        $this->author = $author;
-
-        return $this;
-    }
-
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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 - 88
src/Entity/Message/Sms.php

@@ -24,92 +24,4 @@ use Ramsey\Uuid\Uuid;
 #[ORM\Entity]
 class Sms extends AbstractMessage
 {
-    #[ORM\ManyToOne(inversedBy: 'sms')]
-    #[ORM\JoinColumn(nullable: true)]
-    private ?Access $author = null;
-
-    /** @var Collection<int, ReportSms> */
-    #[ORM\OneToMany(targetEntity: ReportSms::class, mappedBy: 'sms', cascade: ['persist'], orphanRemoval: true)]
-    private Collection $reports;
-
-    /** @var Collection<int, Tagg> */
-    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'sms', cascade: ['persist'])]
-    #[ORM\JoinTable(name: 'tag_message')]
-    #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id')]
-    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected Collection $tags;
-
-    public function __construct()
-    {
-        $this->uuid = Uuid::uuid4();
-        $this->reports = new ArrayCollection();
-        $this->tags = new ArrayCollection();
-        parent::__construct();
-    }
-
-    public function getAuthor(): ?Access
-    {
-        return $this->author;
-    }
-
-    public function setAuthor(?Access $author): self
-    {
-        $this->author = $author;
-
-        return $this;
-    }
-
-    /**
-     * @return Collection<int, ReportSms>
-     */
-    public function getReports(): Collection
-    {
-        return $this->reports;
-    }
-
-    public function addReport(ReportSms $report): self
-    {
-        if (!$this->reports->contains($report)) {
-            $this->reports[] = $report;
-            $report->setSms($this);
-        }
-
-        return $this;
-    }
-
-    public function removeReport(ReportSms $report): self
-    {
-        if ($this->reports->removeElement($report)) {
-            // set the owning side to null (unless already changed)
-            if ($report->getSms() === $this) {
-                $report->setSms(null);
-            }
-        }
-
-        return $this;
-    }
-
-    /**
-     * @return Collection<int, Tagg>
-     */
-    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 - 7
src/Entity/Place/AbstractPlace.php

@@ -4,15 +4,8 @@ declare(strict_types=1);
 
 namespace App\Entity\Place;
 
-use App\Entity\Booking\Course;
-use App\Entity\Booking\EducationalProject;
-use App\Entity\Booking\Event;
-use App\Entity\Booking\Examen;
 use App\Entity\Core\AddressPostal;
-use App\Entity\Core\ContactPoint;
 use App\Entity\Core\Tagg;
-use App\Entity\Organization\Organization;
-use App\Entity\Product\Equipment;
 // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;

+ 4 - 32
src/Entity/Product/Equipment.php

@@ -55,19 +55,19 @@ class Equipment extends AbstractProduct
     protected ?EquipmentList $equipmentList = null;
 
     /** @var Collection<int, EquipmentComposition> */
-    #[ORM\OneToMany(mappedBy: 'parent', targetEntity: EquipmentComposition::class, orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EquipmentComposition::class, mappedBy: 'parent', orphanRemoval: true)]
     protected Collection $equipmentComposition;
 
     /** @var Collection<int, EquipmentRepair> */
-    #[ORM\OneToMany(mappedBy: 'equipment', targetEntity: EquipmentRepair::class, orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EquipmentRepair::class, mappedBy: 'equipment', orphanRemoval: true)]
     protected Collection $equipmentRepair;
 
     /** @var Collection<int, EquipmentControl> */
-    #[ORM\OneToMany(mappedBy: 'equipment', targetEntity: EquipmentControl::class, cascade: ['persist'], orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EquipmentControl::class, mappedBy: 'equipment', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $equipmentControl;
 
     /** @var Collection<int, EquipmentLoan> */
-    #[ORM\OneToMany(mappedBy: 'equipment', targetEntity: EquipmentLoan::class, cascade: ['persist'], orphanRemoval: true)]
+    #[ORM\OneToMany(targetEntity: EquipmentLoan::class, mappedBy: 'equipment', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $equipmentLoan;
 
     #[ORM\ManyToOne(inversedBy: 'equipmentSuppliers')]
@@ -96,10 +96,6 @@ class Equipment extends AbstractProduct
     #[ORM\OneToMany(targetEntity: EquipmentComposition::class, mappedBy: 'children', cascade: [], orphanRemoval: true)]
     protected Collection $equipmentCompositionChildren;
 
-    /** @var Collection<int, EquipmentLoan> */
-    #[ORM\OneToMany(targetEntity: EquipmentLoan::class, mappedBy: 'equipment', cascade: [], orphanRemoval: true)]
-    protected Collection $equipmentLoanFiltered;
-
     /** @var Collection<int, ExamenConvocation> */
     #[ORM\ManyToMany(targetEntity: ExamenConvocation::class, mappedBy: 'equipments', cascade: [], orphanRemoval: false)]
     protected Collection $examenConvocations;
@@ -418,30 +414,6 @@ class Equipment extends AbstractProduct
         return $this;
     }
 
-    public function getEquipmentLoanFiltered(): Collection
-    {
-        return $this->equipmentLoanFiltered;
-    }
-
-    public function addEquipmentLoanFiltered(EquipmentLoan $equipmentLoanFiltered): self
-    {
-        if (!$this->equipmentLoanFiltered->contains($equipmentLoanFiltered)) {
-            $this->equipmentLoanFiltered[] = $equipmentLoanFiltered;
-            $equipmentLoanFiltered->setEquipment($this);
-        }
-
-        return $this;
-    }
-
-    public function removeEquipmentLoanFiltered(EquipmentLoan $equipmentLoanFiltered): self
-    {
-        if ($this->equipmentLoanFiltered->removeElement($equipmentLoanFiltered)) {
-            $equipmentLoanFiltered->setEquipment(null);
-        }
-
-        return $this;
-    }
-
     public function getExamenConvocations(): Collection
     {
         return $this->examenConvocations;