CriteriaNotation.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Education;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Entity\Organization\Organization;
  7. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13. * Classe ... qui ...
  14. */
  15. #[ApiResource(operations: [])]
  16. //#[Auditable]
  17. #[ORM\Entity]
  18. class CriteriaNotation
  19. {
  20. #[ORM\Id]
  21. #[ORM\Column]
  22. #[ORM\GeneratedValue]
  23. private ?int $id = null;
  24. #[ORM\ManyToOne(inversedBy: 'critereNotations')]
  25. #[ORM\JoinColumn(nullable: false)]
  26. private Organization $organization;
  27. #[ORM\OneToMany(mappedBy: 'criteriaNotation', targetEntity: EducationNotation::class)]
  28. private Collection $educationNotations;
  29. #[ORM\OneToMany(mappedBy: 'criteriaNotation', targetEntity: CustomNotation::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  30. private Collection $customNotation;
  31. #[ORM\OneToMany(mappedBy: 'criteriaNotation', targetEntity: EducationNotationCriteriaConfig::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  32. private Collection $educationNotationCriteriaConfigs;
  33. #[ORM\Column]
  34. #[Assert\Choice(callback: ['\\App\\Enum\\Education\\TypeCriteriaEnum', 'toArray'], message: 'invalid-type')]
  35. private string $type;
  36. #[ORM\Column]
  37. #[Assert\GreaterThanOrEqual(value: 0)]
  38. #[Assert\Range(notInRangeMessage: 'between_{{ min }}_and_{{ max }}', min: 0, max: 100)]
  39. private ?int $noteMax;
  40. public function __construct()
  41. {
  42. $this->educationNotations = new ArrayCollection();
  43. $this->customNotation = new ArrayCollection();
  44. $this->educationNotationCriteriaConfigs = new ArrayCollection();
  45. }
  46. public function getId(): ?int
  47. {
  48. return $this->id;
  49. }
  50. public function getOrganization(): ?Organization
  51. {
  52. return $this->organization;
  53. }
  54. public function setOrganization(?Organization $organization): self
  55. {
  56. $this->organization = $organization;
  57. return $this;
  58. }
  59. /**
  60. * @return Collection<int, EducationNotation>
  61. */
  62. public function getEducationNotations(): Collection
  63. {
  64. return $this->educationNotations;
  65. }
  66. public function addEducationNotation(EducationNotation $educationNotation): self
  67. {
  68. if (!$this->educationNotations->contains($educationNotation)) {
  69. $this->educationNotations[] = $educationNotation;
  70. $educationNotation->setCriteriaNotation($this);
  71. }
  72. return $this;
  73. }
  74. public function removeEducationNotation(EducationNotation $educationNotation): self
  75. {
  76. if ($this->educationNotations->removeElement($educationNotation)) {
  77. // set the owning side to null (unless already changed)
  78. if ($educationNotation->getCriteriaNotation() === $this) {
  79. $educationNotation->setCriteriaNotation(null);
  80. }
  81. }
  82. return $this;
  83. }
  84. /**
  85. * @return Collection<int, CustomNotation>
  86. */
  87. public function getCustomNotation(): Collection
  88. {
  89. return $this->customNotation;
  90. }
  91. public function addCustomNotation(CustomNotation $customNotation): self
  92. {
  93. if (!$this->customNotation->contains($customNotation)) {
  94. $this->customNotation[] = $customNotation;
  95. $customNotation->setCriteriaNotation($this);
  96. }
  97. return $this;
  98. }
  99. public function removeCustomNotation(CustomNotation $customNotation): self
  100. {
  101. if ($this->customNotation->removeElement($customNotation)) {
  102. // set the owning side to null (unless already changed)
  103. if ($customNotation->getCriteriaNotation() === $this) {
  104. $customNotation->setCriteriaNotation(null);
  105. }
  106. }
  107. return $this;
  108. }
  109. /**
  110. * @return Collection<int, EducationNotationCriteriaConfig>
  111. */
  112. public function getEducationNotationCriteriaConfigs(): Collection
  113. {
  114. return $this->educationNotationCriteriaConfigs;
  115. }
  116. public function addEducationNotationCriteriaConfig(EducationNotationCriteriaConfig $educationNotationCriteriaConfig): self
  117. {
  118. if (!$this->educationNotationCriteriaConfigs->contains($educationNotationCriteriaConfig)) {
  119. $this->educationNotationCriteriaConfigs[] = $educationNotationCriteriaConfig;
  120. $educationNotationCriteriaConfig->setCriteriaNotation($this);
  121. }
  122. return $this;
  123. }
  124. public function removeEducationNotationCriteriaConfig(EducationNotationCriteriaConfig $educationNotationCriteriaConfig): self
  125. {
  126. if ($this->educationNotationCriteriaConfigs->removeElement($educationNotationCriteriaConfig)) {
  127. // set the owning side to null (unless already changed)
  128. if ($educationNotationCriteriaConfig->getCriteriaNotation() === $this) {
  129. $educationNotationCriteriaConfig->setCriteriaNotation(null);
  130. }
  131. }
  132. return $this;
  133. }
  134. public function getType(): ?string
  135. {
  136. return $this->type;
  137. }
  138. public function setType(string $type): self
  139. {
  140. $this->type = $type;
  141. return $this;
  142. }
  143. public function getNoteMax(): ?int
  144. {
  145. return $this->noteMax;
  146. }
  147. public function setNoteMax(int $noteMax): self
  148. {
  149. $this->noteMax = $noteMax;
  150. return $this;
  151. }
  152. }