Intangible.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Product;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Entity\Core\Tagg;
  7. use App\Entity\Organization\Organization;
  8. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use App\Entity\Billing\AccessIntangible;
  13. use App\Entity\Education\EducationCurriculum;
  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. private string $discr = 'intangible';
  27. #[ORM\ManyToOne(inversedBy: 'intangibles')]
  28. protected Organization $organization;
  29. #[ORM\ManyToMany(targetEntity: EducationCurriculum::class)]
  30. private Collection $educationCurriculums;
  31. #[ORM\OneToMany(mappedBy: 'intangible', targetEntity: AccessIntangible::class, cascade: ['persist'], orphanRemoval: true)]
  32. private 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. private Collection $tags;
  38. public function __construct()
  39. {
  40. $this->educationCurriculums = new ArrayCollection();
  41. $this->accessIntangibles = new ArrayCollection();
  42. $this->tags = new ArrayCollection();
  43. }
  44. public function getDiscr(): ?string
  45. {
  46. return $this->discr;
  47. }
  48. public function setDiscr(string $discr): self
  49. {
  50. $this->discr = $discr;
  51. return $this;
  52. }
  53. public function getOrganization(): ?Organization
  54. {
  55. return $this->organization;
  56. }
  57. public function setOrganization(?Organization $organization): self
  58. {
  59. $this->organization = $organization;
  60. return $this;
  61. }
  62. /**
  63. * @return Collection<int, EducationCurriculum>
  64. */
  65. public function getEducationCurriculums(): Collection
  66. {
  67. return $this->educationCurriculums;
  68. }
  69. public function addEducationCurriculum(EducationCurriculum $educationCurriculum): self
  70. {
  71. if (!$this->educationCurriculums->contains($educationCurriculum)) {
  72. $this->educationCurriculums[] = $educationCurriculum;
  73. }
  74. return $this;
  75. }
  76. public function removeEducationCurriculum(EducationCurriculum $educationCurriculum): self
  77. {
  78. $this->educationCurriculums->removeElement($educationCurriculum);
  79. return $this;
  80. }
  81. /**
  82. * @return Collection<int, AccessIntangible>
  83. */
  84. public function getAccessIntangibles(): Collection
  85. {
  86. return $this->accessIntangibles;
  87. }
  88. public function addAccessIntangible(AccessIntangible $accessIntangible): self
  89. {
  90. if (!$this->accessIntangibles->contains($accessIntangible)) {
  91. $this->accessIntangibles[] = $accessIntangible;
  92. $accessIntangible->setIntangible($this);
  93. }
  94. return $this;
  95. }
  96. public function removeAccessIntangible(AccessIntangible $accessIntangible): self
  97. {
  98. if ($this->accessIntangibles->removeElement($accessIntangible)) {
  99. // set the owning side to null (unless already changed)
  100. if ($accessIntangible->getIntangible() === $this) {
  101. $accessIntangible->setIntangible(null);
  102. }
  103. }
  104. return $this;
  105. }
  106. /**
  107. * @return Collection<int, Tagg>
  108. */
  109. public function getTags(): Collection
  110. {
  111. return $this->tags;
  112. }
  113. public function addTag(Tagg $tag): self
  114. {
  115. if (!$this->tags->contains($tag)) {
  116. $this->tags[] = $tag;
  117. }
  118. return $this;
  119. }
  120. public function removeTag(Tagg $tag): self
  121. {
  122. $this->tags->removeElement($tag);
  123. return $this;
  124. }
  125. }