CriteriaNotation.php 5.6 KB

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