Jury.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Organization;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Entity\Access\Access;
  7. use App\Entity\Booking\Examen;
  8. use App\Entity\Core\Tagg;
  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. * Classe ... qui ...
  15. */
  16. #[ApiResource(operations: [])]
  17. //#[Auditable]
  18. #[ORM\Entity]
  19. class Jury
  20. {
  21. #[ORM\Id]
  22. #[ORM\Column]
  23. #[ORM\GeneratedValue]
  24. private ?int $id = null;
  25. #[ORM\ManyToOne(inversedBy: 'juries')]
  26. #[ORM\JoinColumn(nullable: false)]
  27. private Organization $organization;
  28. #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'juryMembers', cascade: ['persist'])]
  29. #[ORM\JoinTable(name: 'juries_members')]
  30. private Collection $members;
  31. #[ORM\OneToMany(mappedBy: 'jury', targetEntity: Examen::class)]
  32. private Collection $examens;
  33. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'juries', cascade: ['persist'])]
  34. #[ORM\JoinTable(name: 'tag_jury')]
  35. #[ORM\JoinColumn(name: 'jury_id', referencedColumnName: 'id')]
  36. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  37. private Collection $tags;
  38. public function __construct()
  39. {
  40. $this->members = new ArrayCollection();
  41. $this->examens = new ArrayCollection();
  42. $this->tags = new ArrayCollection();
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getOrganization(): ?Organization
  49. {
  50. return $this->organization;
  51. }
  52. public function setOrganization(?Organization $organization): self
  53. {
  54. $this->organization = $organization;
  55. return $this;
  56. }
  57. /**
  58. * @return Collection<int, Access>
  59. */
  60. public function getMembers(): Collection
  61. {
  62. return $this->members;
  63. }
  64. public function addMember(Access $member): self
  65. {
  66. if (!$this->members->contains($member)) {
  67. $this->members[] = $member;
  68. }
  69. return $this;
  70. }
  71. public function removeMember(Access $member): self
  72. {
  73. $this->members->removeElement($member);
  74. return $this;
  75. }
  76. /**
  77. * @return Collection<int, Examen>
  78. */
  79. public function getExamens(): Collection
  80. {
  81. return $this->examens;
  82. }
  83. public function addExamen(Examen $examen): self
  84. {
  85. if (!$this->examens->contains($examen)) {
  86. $this->examens[] = $examen;
  87. $examen->setJury($this);
  88. }
  89. return $this;
  90. }
  91. public function removeExamen(Examen $examen): self
  92. {
  93. if ($this->examens->removeElement($examen)) {
  94. // set the owning side to null (unless already changed)
  95. if ($examen->getJury() === $this) {
  96. $examen->setJury(null);
  97. }
  98. }
  99. return $this;
  100. }
  101. /**
  102. * @return Collection<int, Tagg>
  103. */
  104. public function getTags(): Collection
  105. {
  106. return $this->tags;
  107. }
  108. public function addTag(Tagg $tag): self
  109. {
  110. if (!$this->tags->contains($tag)) {
  111. $this->tags[] = $tag;
  112. }
  113. return $this;
  114. }
  115. public function removeTag(Tagg $tag): self
  116. {
  117. $this->tags->removeElement($tag);
  118. return $this;
  119. }
  120. }