EducationCategory.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Education;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Organization\Organization;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * Catégorie de l'enseignement Education.
  12. */
  13. #[ApiResource(operations: [])]
  14. // #[Auditable]
  15. #[ORM\Entity]
  16. class EducationCategory
  17. {
  18. #[ORM\Id]
  19. #[ORM\Column]
  20. #[ORM\GeneratedValue]
  21. private ?int $id = null;
  22. #[ORM\ManyToOne(inversedBy: 'educationCategories')]
  23. #[ORM\JoinColumn(nullable: false)]
  24. private Organization $organization;
  25. /** @var Collection<int, Education> */
  26. #[ORM\OneToMany(targetEntity: Education::class, mappedBy: 'educationCategory', orphanRemoval: true)]
  27. private Collection $educations;
  28. public function __construct()
  29. {
  30. $this->educations = new ArrayCollection();
  31. }
  32. public function getId(): ?int
  33. {
  34. return $this->id;
  35. }
  36. public function getOrganization(): ?Organization
  37. {
  38. return $this->organization;
  39. }
  40. public function setOrganization(?Organization $organization): self
  41. {
  42. $this->organization = $organization;
  43. return $this;
  44. }
  45. /**
  46. * @return Collection<int, Education>
  47. */
  48. public function getEducations(): Collection
  49. {
  50. return $this->educations;
  51. }
  52. public function addEducation(Education $education): self
  53. {
  54. if (!$this->educations->contains($education)) {
  55. $this->educations[] = $education;
  56. $education->setEducationCategory($this);
  57. }
  58. return $this;
  59. }
  60. public function removeEducation(Education $education): self
  61. {
  62. if ($this->educations->removeElement($education)) {
  63. // set the owning side to null (unless already changed)
  64. if ($education->getEducationCategory() === $this) {
  65. $education->setEducationCategory(null);
  66. }
  67. }
  68. return $this;
  69. }
  70. }