Intangible.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. }
  48. public function getDiscr(): ?string
  49. {
  50. return $this->discr;
  51. }
  52. public function setDiscr(string $discr): self
  53. {
  54. $this->discr = $discr;
  55. return $this;
  56. }
  57. public function getOrganization(): ?Organization
  58. {
  59. return $this->organization;
  60. }
  61. public function setOrganization(?Organization $organization): self
  62. {
  63. $this->organization = $organization;
  64. return $this;
  65. }
  66. /**
  67. * @return Collection<int, EducationCurriculum>
  68. */
  69. public function getEducationCurriculums(): Collection
  70. {
  71. return $this->educationCurriculums;
  72. }
  73. public function addEducationCurriculum(EducationCurriculum $educationCurriculum): self
  74. {
  75. if (!$this->educationCurriculums->contains($educationCurriculum)) {
  76. $this->educationCurriculums[] = $educationCurriculum;
  77. }
  78. return $this;
  79. }
  80. public function removeEducationCurriculum(EducationCurriculum $educationCurriculum): self
  81. {
  82. $this->educationCurriculums->removeElement($educationCurriculum);
  83. return $this;
  84. }
  85. /**
  86. * @return Collection<int, AccessIntangible>
  87. */
  88. public function getAccessIntangibles(): Collection
  89. {
  90. return $this->accessIntangibles;
  91. }
  92. public function addAccessIntangible(AccessIntangible $accessIntangible): self
  93. {
  94. if (!$this->accessIntangibles->contains($accessIntangible)) {
  95. $this->accessIntangibles[] = $accessIntangible;
  96. $accessIntangible->setIntangible($this);
  97. }
  98. return $this;
  99. }
  100. public function removeAccessIntangible(AccessIntangible $accessIntangible): self
  101. {
  102. if ($this->accessIntangibles->removeElement($accessIntangible)) {
  103. // set the owning side to null (unless already changed)
  104. if ($accessIntangible->getIntangible() === $this) {
  105. $accessIntangible->setIntangible(null);
  106. }
  107. }
  108. return $this;
  109. }
  110. /**
  111. * @return Collection<int, Tagg>
  112. */
  113. public function getTags(): Collection
  114. {
  115. return $this->tags;
  116. }
  117. public function addTag(Tagg $tag): self
  118. {
  119. if (!$this->tags->contains($tag)) {
  120. $this->tags[] = $tag;
  121. }
  122. return $this;
  123. }
  124. public function removeTag(Tagg $tag): self
  125. {
  126. $this->tags->removeElement($tag);
  127. return $this;
  128. }
  129. function getEducationCurriculumPacks(): Collection
  130. {
  131. return $this->educationCurriculumPacks;
  132. }
  133. function setEducationCurriculumPacks(Collection $educationCurriculumPacks): self
  134. {
  135. $this->educationCurriculumPacks = $educationCurriculumPacks;
  136. return $this;
  137. }
  138. function getIntangiblePriceAndDiscount(): IntangiblePriceAndDiscount
  139. {
  140. return $this->intangiblePriceAndDiscount;
  141. }
  142. function setIntangiblePriceAndDiscount(IntangiblePriceAndDiscount $intangiblePriceAndDiscount): self
  143. {
  144. $this->intangiblePriceAndDiscount = $intangiblePriceAndDiscount;
  145. return $this;
  146. }
  147. }