Intangible.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Product;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Billing\AccessIntangible;
  6. use App\Entity\Core\Tagg;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use App\Entity\Education\EducationCurriculum;
  9. use App\Entity\Education\EducationCurriculumPack;
  10. use App\Entity\Organization\Organization;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. /**
  15. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Intangible, et supprimer l'attribut discr.
  16. * @todo : migration table tag_product
  17. * Classe ... qui ...
  18. */
  19. #[ApiResource(operations: [])]
  20. // #[Auditable]
  21. #[ORM\Entity]
  22. #[ORM\Table(name: 'Product')]
  23. class Intangible extends AbstractProduct
  24. {
  25. #[ORM\Column(length: 255, nullable: false)]
  26. protected string $discr = 'intangible';
  27. #[ORM\ManyToOne(inversedBy: 'intangibles')]
  28. protected Organization $organization;
  29. #[ORM\ManyToMany(targetEntity: EducationCurriculum::class)]
  30. protected Collection $educationCurriculums;
  31. #[ORM\OneToMany(mappedBy: 'intangible', targetEntity: AccessIntangible::class, cascade: ['persist'], orphanRemoval: true)]
  32. protected Collection $accessIntangibles;
  33. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'intangibles', cascade: ['persist'])]
  34. #[ORM\JoinTable(name: 'tag_product')]
  35. #[ORM\JoinColumn(name: 'product_id', referencedColumnName: 'id')]
  36. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  37. protected Collection $tags;
  38. #[ORM\ManyToMany(targetEntity: EducationCurriculumPack::class, inversedBy: 'intangibles', cascade: [], orphanRemoval: false)]
  39. protected Collection $educationCurriculumPacks;
  40. #[ORM\OneToOne(inversedBy: 'intangible', targetEntity: IntangiblePriceAndDiscount::class, cascade: ['persist'])]
  41. protected IntangiblePriceAndDiscount $intangiblePriceAndDiscount;
  42. public function __construct()
  43. {
  44. $this->educationCurriculums = new ArrayCollection();
  45. $this->accessIntangibles = new ArrayCollection();
  46. $this->tags = new ArrayCollection();
  47. $this->educationCurriculumPacks = new ArrayCollection();
  48. $this->intangiblePriceAndDiscount = new IntangiblePriceAndDiscount();
  49. parent::__construct();
  50. }
  51. public function getDiscr(): ?string
  52. {
  53. return $this->discr;
  54. }
  55. public function setDiscr(string $discr): self
  56. {
  57. $this->discr = $discr;
  58. return $this;
  59. }
  60. public function getOrganization(): ?Organization
  61. {
  62. return $this->organization;
  63. }
  64. public function setOrganization(?Organization $organization): self
  65. {
  66. $this->organization = $organization;
  67. return $this;
  68. }
  69. /**
  70. * @return Collection<int, EducationCurriculum>
  71. */
  72. public function getEducationCurriculums(): Collection
  73. {
  74. return $this->educationCurriculums;
  75. }
  76. public function addEducationCurriculum(EducationCurriculum $educationCurriculum): self
  77. {
  78. if (!$this->educationCurriculums->contains($educationCurriculum)) {
  79. $this->educationCurriculums[] = $educationCurriculum;
  80. }
  81. return $this;
  82. }
  83. public function removeEducationCurriculum(EducationCurriculum $educationCurriculum): self
  84. {
  85. $this->educationCurriculums->removeElement($educationCurriculum);
  86. return $this;
  87. }
  88. /**
  89. * @return Collection<int, AccessIntangible>
  90. */
  91. public function getAccessIntangibles(): Collection
  92. {
  93. return $this->accessIntangibles;
  94. }
  95. public function addAccessIntangible(AccessIntangible $accessIntangible): self
  96. {
  97. if (!$this->accessIntangibles->contains($accessIntangible)) {
  98. $this->accessIntangibles[] = $accessIntangible;
  99. $accessIntangible->setIntangible($this);
  100. }
  101. return $this;
  102. }
  103. public function removeAccessIntangible(AccessIntangible $accessIntangible): self
  104. {
  105. if ($this->accessIntangibles->removeElement($accessIntangible)) {
  106. // set the owning side to null (unless already changed)
  107. if ($accessIntangible->getIntangible() === $this) {
  108. $accessIntangible->setIntangible(null);
  109. }
  110. }
  111. return $this;
  112. }
  113. /**
  114. * @return Collection<int, Tagg>
  115. */
  116. public function getTags(): Collection
  117. {
  118. return $this->tags;
  119. }
  120. public function addTag(Tagg $tag): self
  121. {
  122. if (!$this->tags->contains($tag)) {
  123. $this->tags[] = $tag;
  124. }
  125. return $this;
  126. }
  127. public function removeTag(Tagg $tag): self
  128. {
  129. $this->tags->removeElement($tag);
  130. return $this;
  131. }
  132. function getEducationCurriculumPacks(): Collection
  133. {
  134. return $this->educationCurriculumPacks;
  135. }
  136. function setEducationCurriculumPacks(Collection $educationCurriculumPacks): self
  137. {
  138. $this->educationCurriculumPacks = $educationCurriculumPacks;
  139. return $this;
  140. }
  141. function getIntangiblePriceAndDiscount(): IntangiblePriceAndDiscount
  142. {
  143. return $this->intangiblePriceAndDiscount;
  144. }
  145. function addEducationCurriculumPack(EducationCurriculumPack $educationCurriculumPack): self
  146. {
  147. if (!$this->educationCurriculumPacks->contains($educationCurriculumPack)) {
  148. $this->educationCurriculumPacks[] = $educationCurriculumPack;
  149. }
  150. return $this;
  151. }
  152. function removeEducationCurriculumPack(EducationCurriculumPack $educationCurriculumPack): self
  153. {
  154. $this->educationCurriculumPacks->removeElement($educationCurriculumPack);
  155. return $this;
  156. }
  157. }