Browse Source

replace discr definitions with DiscriminatorColumn attribute

Olivier Massot 11 tháng trước cách đây
mục cha
commit
46b9686d97
32 tập tin đã thay đổi với 67 bổ sung363 xóa
  1. 7 0
      src/Entity/Billing/AbstractBillingPayer.php
  2. 0 3
      src/Entity/Billing/AccessPayer.php
  3. 1 14
      src/Entity/Billing/EducationalProjectPayer.php
  4. 11 0
      src/Entity/Booking/AbstractBooking.php
  5. 11 0
      src/Entity/Booking/AbstractBookingRecur.php
  6. 0 15
      src/Entity/Booking/Course.php
  7. 0 15
      src/Entity/Booking/CourseRecur.php
  8. 0 15
      src/Entity/Booking/EducationalProject.php
  9. 0 15
      src/Entity/Booking/EducationalProjectRecur.php
  10. 0 15
      src/Entity/Booking/Event.php
  11. 0 15
      src/Entity/Booking/EventRecur.php
  12. 0 15
      src/Entity/Booking/Examen.php
  13. 0 15
      src/Entity/Booking/ExamenRecur.php
  14. 0 15
      src/Entity/Booking/OrganizationHoliday.php
  15. 0 15
      src/Entity/Booking/OrganizationHolidayRecur.php
  16. 0 15
      src/Entity/Booking/PersonHoliday.php
  17. 0 15
      src/Entity/Booking/PersonHolidayRecur.php
  18. 11 0
      src/Entity/Core/AbstractControl.php
  19. 11 0
      src/Entity/Core/AbstractRepair.php
  20. 8 3
      src/Entity/Message/AbstractMessage.php
  21. 0 14
      src/Entity/Message/Email.php
  22. 0 14
      src/Entity/Message/Mail.php
  23. 0 14
      src/Entity/Message/Sms.php
  24. 0 15
      src/Entity/Place/PlaceControl.php
  25. 0 15
      src/Entity/Place/PlaceRepair.php
  26. 0 15
      src/Entity/Place/RoomControl.php
  27. 0 15
      src/Entity/Place/RoomRepair.php
  28. 7 1
      src/Entity/Product/AbstractProduct.php
  29. 0 15
      src/Entity/Product/Equipment.php
  30. 0 15
      src/Entity/Product/EquipmentControl.php
  31. 0 15
      src/Entity/Product/EquipmentRepair.php
  32. 0 15
      src/Entity/Product/Intangible.php

+ 7 - 0
src/Entity/Billing/AbstractBillingPayer.php

@@ -12,6 +12,13 @@ use Doctrine\ORM\Mapping as ORM;
  * Classe de base de @see  AccessPayer, EducationalProjectPayer.
  */
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'access' => AccessPayer::class,
+        'educationalproject' => EducationalProjectPayer::class,
+    ]
+)]
 abstract class AbstractBillingPayer
 {
     #[ORM\Id]

+ 0 - 3
src/Entity/Billing/AccessPayer.php

@@ -21,9 +21,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity(repositoryClass: AccessPayerRepository::class)]
 class AccessPayer extends AbstractBillingPayer
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'access';
-
     #[ORM\ManyToOne(inversedBy: 'billingPayers')]
     private ?Access $accessPayer = null;
 

+ 1 - 14
src/Entity/Billing/EducationalProjectPayer.php

@@ -19,27 +19,14 @@ use Doctrine\ORM\Mapping as ORM;
 // #[Auditable]
 #[ORM\Table(name: 'BillingPayer')]
 #[ORM\Entity]
-class EducationalProjectPayer
+class EducationalProjectPayer extends AbstractBillingPayer
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'educationalproject';
-
-    #[ORM\Id]
-    #[ORM\Column]
-    #[ORM\GeneratedValue]
-    private ?int $id = null;
-
     #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billingEducationalProjectPayers')]
     private ?Access $educationalProjectPayer = null;
 
     #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billingReceivers')]
     private ?EducationalProject $educationalProjectReceiver = null;
 
-    public function getId(): ?int
-    {
-        return $this->id;
-    }
-
     public function getEducationalProjectPayer(): ?Access
     {
         return $this->educationalProjectPayer;

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

@@ -16,6 +16,17 @@ use Doctrine\ORM\Mapping as ORM;
 #[ActivityYearConstraintAware(startYearFieldName: 'startYear', endYearFieldName: 'endYear')]
 #[OrganizationDefaultValue(fieldName: 'organization')]
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'educationalproject' => EducationalProject::class,
+        'course' => Course::class,
+        'event' => Event::class,
+        'examen' => Examen::class,
+        'organizationholiday' => OrganizationHoliday::class,
+        'personholiday' => PersonHoliday::class,
+    ]
+)]
 abstract class AbstractBooking
 {
     use ActivityYearTrait;

+ 11 - 0
src/Entity/Booking/AbstractBookingRecur.php

@@ -10,6 +10,17 @@ use Doctrine\ORM\Mapping as ORM;
  * Classe ... qui ...
  */
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'educationalproject' => EducationalProjectRecur::class,
+        'course' => CourseRecur::class,
+        'event' => EventRecur::class,
+        'examen' => ExamenRecur::class,
+        'organizationholiday' => OrganizationHolidayRecur::class,
+        'personholiday' => PersonHolidayRecur::class,
+    ]
+)]
 abstract class AbstractBookingRecur
 {
     #[ORM\Id]

+ 0 - 15
src/Entity/Booking/Course.php

@@ -36,9 +36,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Booking')]
 class Course extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'course';
-
     /** @var Collection<int, CourseRecur> */
     #[ORM\OneToMany(targetEntity: CourseRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
     private Collection $eventRecur;
@@ -120,18 +117,6 @@ class Course extends AbstractBooking
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     /**
      * @return Collection<int, CourseRecur>
      */

+ 0 - 15
src/Entity/Booking/CourseRecur.php

@@ -19,24 +19,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class CourseRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'course';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?Course $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?Course
     {
         return $this->event;

+ 0 - 15
src/Entity/Booking/EducationalProject.php

@@ -31,9 +31,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class EducationalProject extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'educationalproject';
-
     /** @var Collection<int, EducationalProjectRecur> */
     #[ORM\OneToMany(targetEntity: EducationalProjectRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
     private Collection $eventRecur;
@@ -123,18 +120,6 @@ class EducationalProject extends AbstractBooking
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     /**
      * @return Collection<int, EducationalProjectRecur>
      */

+ 0 - 15
src/Entity/Booking/EducationalProjectRecur.php

@@ -17,24 +17,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class EducationalProjectRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'educationalproject';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?EducationalProject $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?EducationalProject
     {
         return $this->event;

+ 0 - 15
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)]
-    private string $discr = 'event';
-
     #[ORM\ManyToOne(inversedBy: 'events')]
     #[ORM\JoinColumn(nullable: false)]
     protected Organization $organization;
@@ -120,18 +117,6 @@ class Event extends AbstractBooking
         $this->tags = new ArrayCollection();
     }
 
-    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 - 15
src/Entity/Booking/EventRecur.php

@@ -17,24 +17,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'BookingRecur')]
 class EventRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'event';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?Event $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?Event
     {
         return $this->event;

+ 0 - 15
src/Entity/Booking/Examen.php

@@ -29,9 +29,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Booking')]
 class Examen extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'examen';
-
     #[ORM\ManyToOne(inversedBy: 'examens')]
     #[ORM\JoinColumn(nullable: false)]
     protected Organization $organization;
@@ -93,18 +90,6 @@ class Examen extends AbstractBooking
         $this->tags = new ArrayCollection();
     }
 
-    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 - 15
src/Entity/Booking/ExamenRecur.php

@@ -19,24 +19,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class ExamenRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'examen';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?Examen $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?Examen
     {
         return $this->event;

+ 0 - 15
src/Entity/Booking/OrganizationHoliday.php

@@ -23,9 +23,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Booking')]
 class OrganizationHoliday extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'organizationholiday';
-
     /** @var Collection<int, OrganizationHolidayRecur> */
     #[ORM\OneToMany(targetEntity: OrganizationHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
     private Collection $eventRecur;
@@ -39,18 +36,6 @@ class OrganizationHoliday extends AbstractBooking
         $this->eventRecur = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     /**
      * @return Collection<int, OrganizationHolidayRecur>
      */

+ 0 - 15
src/Entity/Booking/OrganizationHolidayRecur.php

@@ -17,24 +17,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class OrganizationHolidayRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'organizationholiday';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?OrganizationHoliday $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?OrganizationHoliday
     {
         return $this->event;

+ 0 - 15
src/Entity/Booking/PersonHoliday.php

@@ -23,9 +23,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Booking')]
 class PersonHoliday extends AbstractBooking
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'personholiday';
-
     /** @var Collection<int, PersonHolidayRecur> */
     #[ORM\OneToMany(targetEntity: PersonHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
     protected Collection $eventRecur;
@@ -38,18 +35,6 @@ class PersonHoliday extends AbstractBooking
         $this->eventRecur = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     /**
      * @return Collection<int, PersonHolidayRecur>
      */

+ 0 - 15
src/Entity/Booking/PersonHolidayRecur.php

@@ -19,24 +19,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class PersonHolidayRecur extends AbstractBookingRecur
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'personholiday';
-
     #[ORM\ManyToOne(inversedBy: 'eventRecur')]
     private ?PersonHoliday $event = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEvent(): ?PersonHoliday
     {
         return $this->event;

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

@@ -5,9 +5,20 @@ declare(strict_types=1);
 namespace App\Entity\Core;
 
 use App\Entity\Access\Access;
+use App\Entity\Place\PlaceControl;
+use App\Entity\Place\RoomControl;
+use App\Entity\Product\EquipmentControl;
 use Doctrine\ORM\Mapping as ORM;
 
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'equipment' => EquipmentControl::class,
+        'place' => PlaceControl::class,
+        'room' => RoomControl::class,
+    ]
+)]
 abstract class AbstractControl
 {
     #[ORM\Id]

+ 11 - 0
src/Entity/Core/AbstractRepair.php

@@ -4,9 +4,20 @@ declare(strict_types=1);
 
 namespace App\Entity\Core;
 
+use App\Entity\Place\PlaceRepair;
+use App\Entity\Place\RoomRepair;
+use App\Entity\Product\EquipmentRepair;
 use Doctrine\ORM\Mapping as ORM;
 
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'room' => RoomRepair::class,
+        'place' => PlaceRepair::class,
+        'equipment' => EquipmentRepair::class,
+    ]
+)]
 abstract class AbstractRepair
 {
     #[ORM\Id]

+ 8 - 3
src/Entity/Message/AbstractMessage.php

@@ -16,6 +16,14 @@ use Ramsey\Uuid\UuidInterface;
  */
 #[ORM\MappedSuperclass]
 #[OrganizationDefaultValue(fieldName: 'organization')]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'sms' => Sms::class,
+        'mail' => Mail::class,
+        'email' => Email::class,
+    ]
+)]
 abstract class AbstractMessage
 {
     /**
@@ -33,9 +41,6 @@ abstract class AbstractMessage
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
-    #[ORM\Column(length: 255, nullable: false)]
-    protected string $discr;
-
     #[ORM\ManyToOne]
     #[ORM\JoinColumn(nullable: true)]
     protected ?Organization $organization = null;

+ 0 - 14
src/Entity/Message/Email.php

@@ -27,8 +27,6 @@ use Ramsey\Uuid\Uuid;
 #[ORM\Entity]
 class Email extends AbstractMessage
 {
-    protected string $discr = 'email';
-
     #[ORM\Column(type: 'boolean', options: ['default' => false])]
     private bool $isSystem = false;
 
@@ -67,18 +65,6 @@ class Email extends AbstractMessage
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function setIsSystem(bool $isSystem): self
     {
         $this->isSystem = $isSystem;

+ 0 - 14
src/Entity/Message/Mail.php

@@ -27,8 +27,6 @@ use Ramsey\Uuid\Uuid;
 #[ORM\Entity]
 class Mail extends AbstractMessage
 {
-    protected string $discr = 'mail';
-
     #[ORM\ManyToOne(inversedBy: 'mails')]
     #[ORM\JoinColumn(nullable: true)]
     private ?Access $author = null;
@@ -54,18 +52,6 @@ class Mail extends AbstractMessage
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getAuthor(): ?Access
     {
         return $this->author;

+ 0 - 14
src/Entity/Message/Sms.php

@@ -26,8 +26,6 @@ use Ramsey\Uuid\Uuid;
 #[ORM\Entity]
 class Sms extends AbstractMessage
 {
-    protected string $discr = 'sms';
-
     #[ORM\ManyToOne(inversedBy: 'sms')]
     #[ORM\JoinColumn(nullable: true)]
     private ?Access $author = null;
@@ -50,18 +48,6 @@ class Sms extends AbstractMessage
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getAuthor(): ?Access
     {
         return $this->author;

+ 0 - 15
src/Entity/Place/PlaceControl.php

@@ -24,9 +24,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Control')]
 class PlaceControl extends AbstractControl
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'place';
-
     #[ORM\ManyToOne(inversedBy: 'controls')]
     private ?Place $place = null;
 
@@ -42,18 +39,6 @@ class PlaceControl extends AbstractControl
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getPlace(): ?Place
     {
         return $this->place;

+ 0 - 15
src/Entity/Place/PlaceRepair.php

@@ -25,9 +25,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Repair')]
 class PlaceRepair extends AbstractRepair
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'place';
-
     #[ORM\ManyToOne(inversedBy: 'placeRepairProviders')]
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     private ?Access $provider = null;
@@ -47,18 +44,6 @@ class PlaceRepair extends AbstractRepair
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getProvider(): ?Access
     {
         return $this->provider;

+ 0 - 15
src/Entity/Place/RoomControl.php

@@ -20,24 +20,9 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Control')]
 class RoomControl extends AbstractControl
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'room';
-
     #[ORM\ManyToOne(inversedBy: 'controls')]
     private ?Room $room = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getRoom(): ?Room
     {
         return $this->room;

+ 0 - 15
src/Entity/Place/RoomRepair.php

@@ -21,9 +21,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Repair')]
 class RoomRepair extends AbstractRepair
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'room';
-
     #[ORM\ManyToOne(inversedBy: 'repairs')]
     private ?Room $room = null;
 
@@ -31,18 +28,6 @@ class RoomRepair extends AbstractRepair
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     private ?Access $provider = null;
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getRoom(): ?Room
     {
         return $this->room;

+ 7 - 1
src/Entity/Product/AbstractProduct.php

@@ -4,13 +4,19 @@ declare(strict_types=1);
 
 namespace App\Entity\Product;
 
-use App\Entity\Organization\Organization;
 use Doctrine\ORM\Mapping as ORM;
 
 /**
  * Classe ... qui ...
  */
 #[ORM\MappedSuperclass]
+#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
+#[ORM\DiscriminatorMap(
+    [
+        'equipment' => Equipment::class,
+        'intangible' => Intangible::class,
+    ]
+)]
 abstract class AbstractProduct
 {
     #[ORM\Id]

+ 0 - 15
src/Entity/Product/Equipment.php

@@ -27,9 +27,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Product')]
 class Equipment extends AbstractProduct
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'equipment';
-
     #[ORM\ManyToOne(inversedBy: 'equipments')]
     protected ?Organization $organization = null;
 
@@ -111,18 +108,6 @@ class Equipment extends AbstractProduct
         $this->tags = new ArrayCollection();
     }
 
-    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 - 15
src/Entity/Product/EquipmentControl.php

@@ -24,9 +24,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Control')]
 class EquipmentControl extends AbstractControl
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'equipment';
-
     #[ORM\ManyToOne(inversedBy: 'equipmentControl')]
     private ?Equipment $equipment = null;
 
@@ -42,18 +39,6 @@ class EquipmentControl extends AbstractControl
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getEquipment(): ?Equipment
     {
         return $this->equipment;

+ 0 - 15
src/Entity/Product/EquipmentRepair.php

@@ -26,9 +26,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Repair')]
 class EquipmentRepair extends AbstractRepair
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'equipment';
-
     #[ORM\ManyToOne(inversedBy: 'equipmentRepairProviders')]
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
     private ?Access $provider = null;
@@ -48,18 +45,6 @@ class EquipmentRepair extends AbstractRepair
         $this->tags = new ArrayCollection();
     }
 
-    public function getDiscr(): ?string
-    {
-        return $this->discr;
-    }
-
-    public function setDiscr(string $discr): self
-    {
-        $this->discr = $discr;
-
-        return $this;
-    }
-
     public function getProvider(): ?Access
     {
         return $this->provider;

+ 0 - 15
src/Entity/Product/Intangible.php

@@ -26,9 +26,6 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Table(name: 'Product')]
 class Intangible extends AbstractProduct
 {
-    #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'intangible';
-
     #[ORM\ManyToOne(inversedBy: 'intangibles')]
     protected ?Organization $organization = null;
 
@@ -54,18 +51,6 @@ class Intangible extends AbstractProduct
         $this->tags = new ArrayCollection();
     }
 
-    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;