src/Entity/CycleLevel.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CycleLevelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCycleLevelRepository::class)]
  8. class CycleLevel
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\Column]
  17.     private ?int $level null;
  18.     // Type d'école auquel ce cycle s'applique (School::TYPE_SECONDAIRE/
  19.     // TYPE_PRIMAIRE/TYPE_MATERNELLE), défini par le super-admin — permet à
  20.     // SchoolSectionType de ne proposer aux écoles primaires/maternelles que
  21.     // leurs propres cycles, jamais ceux du secondaire (et inversement).
  22.     // Nullable = secondaire par défaut (tous les cycles existants avant
  23.     // cette fonctionnalité restent secondaires sans migration nécessaire —
  24.     // voir getEffectiveSchoolType()).
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?int $schoolType null;
  27.     #[ORM\OneToMany(mappedBy'cycle'targetEntityClassLevel::class)]
  28.     private Collection $classLevels;
  29.     #[ORM\OneToMany(mappedBy'cycleLevel'targetEntitySchoolSection::class)]
  30.     private Collection $sections;
  31.     public function __construct()
  32.     {
  33.         $this->classLevels = new ArrayCollection();
  34.         $this->sections = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function __toString(): string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): static
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getLevel(): ?int
  54.     {
  55.         return $this->level;
  56.     }
  57.     public function setLevel(int $level): static
  58.     {
  59.         $this->level $level;
  60.         return $this;
  61.     }
  62.     public function getSchoolType(): ?int
  63.     {
  64.         return $this->schoolType;
  65.     }
  66.     public function setSchoolType(?int $schoolType): static
  67.     {
  68.         $this->schoolType $schoolType;
  69.         return $this;
  70.     }
  71.     /**
  72.      * Type d'école effectif de ce cycle — secondaire si jamais défini par le
  73.      * super-admin (tous les cycles créés avant cette fonctionnalité).
  74.      */
  75.     public function getEffectiveSchoolType(): int
  76.     {
  77.         return $this->schoolType ?? School::TYPE_SECONDAIRE;
  78.     }
  79.     /**
  80.      * @return Collection<int, ClassLevel>
  81.      */
  82.     public function getClassLevels(): Collection
  83.     {
  84.         return $this->classLevels;
  85.     }
  86.     public function addClassLevel(ClassLevel $classLevel): static
  87.     {
  88.         if (!$this->classLevels->contains($classLevel)) {
  89.             $this->classLevels->add($classLevel);
  90.             $classLevel->setCycle($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeClassLevel(ClassLevel $classLevel): static
  95.     {
  96.         if ($this->classLevels->removeElement($classLevel)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($classLevel->getCycle() === $this) {
  99.                 $classLevel->setCycle(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, SchoolSection>
  106.      */
  107.     public function getSections(): Collection
  108.     {
  109.         return $this->sections;
  110.     }
  111.     public function addSection(SchoolSection $section): static
  112.     {
  113.         if (!$this->sections->contains($section)) {
  114.             $this->sections->add($section);
  115.             $section->setCycleLevel($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeSection(SchoolSection $section): static
  120.     {
  121.         if ($this->sections->removeElement($section)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($section->getCycleLevel() === $this) {
  124.                 $section->setCycleLevel(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129. }