PersonHoliday.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use App\Entity\Core\Tagg;
  8. use App\Entity\Organization\Organization;
  9. use App\Entity\Product\Equipment;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. /**
  14. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table PersonHoliday, et supprimer l'attribut discr.
  15. *
  16. * Classe ... qui ...
  17. */
  18. #[ApiResource(operations: [])]
  19. // #[Auditable]
  20. #[ORM\Entity]
  21. #[ORM\Table(name: 'Booking')]
  22. class PersonHoliday extends AbstractBooking
  23. {
  24. #[ORM\Column(length: 255, nullable: false)]
  25. private string $discr = 'personholiday';
  26. #[ORM\OneToMany(mappedBy: 'event', targetEntity: PersonHolidayRecur::class, cascade: ['persist'], orphanRemoval: true)]
  27. protected Collection $eventRecur;
  28. #[ORM\ManyToOne(inversedBy: 'holidays')]
  29. private Access $access;
  30. #[ORM\ManyToOne(targetEntity: Organization::class, cascade: [])]
  31. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  32. protected Organization $organization;
  33. public function __construct()
  34. {
  35. $this->eventRecur = new ArrayCollection();
  36. $this->organizer = new ArrayCollection();
  37. $this->equipments = new ArrayCollection();
  38. $this->tags = new ArrayCollection();
  39. parent::__construct();
  40. }
  41. public function getDiscr(): ?string
  42. {
  43. return $this->discr;
  44. }
  45. public function setDiscr(string $discr): self
  46. {
  47. $this->discr = $discr;
  48. return $this;
  49. }
  50. /**
  51. * @return Collection<int, PersonHolidayRecur>
  52. */
  53. public function getEventRecur(): Collection
  54. {
  55. return $this->eventRecur;
  56. }
  57. public function addEventRecur(PersonHolidayRecur $eventRecur): self
  58. {
  59. if (!$this->eventRecur->contains($eventRecur)) {
  60. $this->eventRecur[] = $eventRecur;
  61. $eventRecur->setEvent($this);
  62. }
  63. return $this;
  64. }
  65. public function removeEventRecur(PersonHolidayRecur $eventRecur): self
  66. {
  67. if ($this->eventRecur->removeElement($eventRecur)) {
  68. // set the owning side to null (unless already changed)
  69. if ($eventRecur->getEvent() === $this) {
  70. $eventRecur->setEvent(null);
  71. }
  72. }
  73. return $this;
  74. }
  75. public function getAccess(): ?Access
  76. {
  77. return $this->access;
  78. }
  79. public function setAccess(?Access $access): self
  80. {
  81. $this->access = $access;
  82. return $this;
  83. }
  84. function getOrganization(): Organization
  85. {
  86. return $this->organization;
  87. }
  88. function setOrganization(Organization $organization): self
  89. {
  90. $this->organization = $organization;
  91. return $this;
  92. }
  93. }