Activity.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Organization;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\Categories;
  6. use App\Entity\Core\File;
  7. use App\Entity\Core\Tagg;
  8. use App\Entity\Person\PersonActivity;
  9. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. /**
  14. * Types d'activités proposées par une structure.
  15. */
  16. #[ApiResource(operations: [])]
  17. // #[Auditable]
  18. #[ORM\Entity]
  19. class Activity
  20. {
  21. #[ORM\Id]
  22. #[ORM\Column]
  23. #[ORM\GeneratedValue]
  24. private ?int $id = null;
  25. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'activityLogos')]
  26. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  27. private ?File $logo = null;
  28. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'activityImages')]
  29. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  30. private ?File $imageActivity = null;
  31. #[ORM\ManyToOne]
  32. private ?ActivityType $activityType = null;
  33. #[ORM\ManyToOne(inversedBy: 'activities')]
  34. #[ORM\JoinColumn(nullable: false)]
  35. private Organization $organization;
  36. /** @var Collection<int, Categories> */
  37. #[ORM\ManyToMany(targetEntity: Categories::class, cascade: ['persist'])]
  38. private Collection $categories;
  39. /** @var Collection<int, PersonActivity> */
  40. #[ORM\OneToMany(targetEntity: PersonActivity::class, mappedBy: 'activity')]
  41. private Collection $personActivities;
  42. /** @var Collection<int, Tagg> */
  43. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'activities', cascade: ['persist'])]
  44. #[ORM\JoinTable(name: 'tag_activity')]
  45. #[ORM\JoinColumn(name: 'activity_id', referencedColumnName: 'id')]
  46. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  47. private Collection $tags;
  48. #[ORM\ManyToOne(targetEntity: TypeOfPractice::class, cascade: [])]
  49. protected ?TypeOfPractice $typeOfSection;
  50. public function __construct()
  51. {
  52. $this->categories = new ArrayCollection();
  53. $this->personActivities = new ArrayCollection();
  54. $this->tags = new ArrayCollection();
  55. }
  56. public function getId(): ?int
  57. {
  58. return $this->id;
  59. }
  60. public function getLogo(): ?File
  61. {
  62. return $this->logo;
  63. }
  64. public function setLogo(?File $logo): self
  65. {
  66. $this->logo = $logo;
  67. return $this;
  68. }
  69. public function getImageActivity(): ?File
  70. {
  71. return $this->imageActivity;
  72. }
  73. public function setImageActivity(?File $imageActivity): self
  74. {
  75. $this->imageActivity = $imageActivity;
  76. return $this;
  77. }
  78. public function getActivityType(): ?ActivityType
  79. {
  80. return $this->activityType;
  81. }
  82. public function setActivityType(?ActivityType $activityType): self
  83. {
  84. $this->activityType = $activityType;
  85. return $this;
  86. }
  87. public function getOrganization(): ?Organization
  88. {
  89. return $this->organization;
  90. }
  91. public function setOrganization(?Organization $organization): self
  92. {
  93. $this->organization = $organization;
  94. return $this;
  95. }
  96. /**
  97. * @return Collection<int, Categories>
  98. */
  99. public function getCategories(): Collection
  100. {
  101. return $this->categories;
  102. }
  103. public function addCategory(Categories $category): self
  104. {
  105. if (!$this->categories->contains($category)) {
  106. $this->categories[] = $category;
  107. }
  108. return $this;
  109. }
  110. public function removeCategory(Categories $category): self
  111. {
  112. $this->categories->removeElement($category);
  113. return $this;
  114. }
  115. /**
  116. * @return Collection<int, PersonActivity>
  117. */
  118. public function getPersonActivities(): Collection
  119. {
  120. return $this->personActivities;
  121. }
  122. public function addPersonActivity(PersonActivity $personActivity): self
  123. {
  124. if (!$this->personActivities->contains($personActivity)) {
  125. $this->personActivities[] = $personActivity;
  126. $personActivity->setActivity($this);
  127. }
  128. return $this;
  129. }
  130. public function removePersonActivity(PersonActivity $personActivity): self
  131. {
  132. if ($this->personActivities->removeElement($personActivity)) {
  133. // set the owning side to null (unless already changed)
  134. if ($personActivity->getActivity() === $this) {
  135. $personActivity->setActivity(null);
  136. }
  137. }
  138. return $this;
  139. }
  140. /**
  141. * @return Collection<int, Tagg>
  142. */
  143. public function getTags(): Collection
  144. {
  145. return $this->tags;
  146. }
  147. public function addTag(Tagg $tag): self
  148. {
  149. if (!$this->tags->contains($tag)) {
  150. $this->tags[] = $tag;
  151. }
  152. return $this;
  153. }
  154. public function removeTag(Tagg $tag): self
  155. {
  156. $this->tags->removeElement($tag);
  157. return $this;
  158. }
  159. public function getTypeOfSection(): ?TypeOfPractice
  160. {
  161. return $this->typeOfSection;
  162. }
  163. public function setTypeOfSection(?TypeOfPractice $typeOfSection): self
  164. {
  165. $this->typeOfSection = $typeOfSection;
  166. return $this;
  167. }
  168. }