src/Entity/ClassLevel.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClassLevelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassClassLevelRepository::class)]
  8. class ClassLevel
  9. {
  10.     // Systèmes d'évaluation possibles pour une classe (voir TheClassEvaluationSystem).
  11.     public const SYSTEM_SEQUENCE 'sequence';
  12.     public const SYSTEM_COMPETENCE 'competence';
  13.     public const SYSTEM_LIBRE 'libre';
  14.     // Sous-matières (Oral/Écrit/Pratique/Attitude...) chacune avec son propre barème,
  15.     // notes mensuelles par trimestre — écoles primaires/maternelles (School::isPrimaryOrKindergarten()).
  16.     public const SYSTEM_PRIMARY 'primary';
  17.     public const EVALUATION_SYSTEMS = [
  18.         self::SYSTEM_SEQUENCE,
  19.         self::SYSTEM_COMPETENCE,
  20.         self::SYSTEM_LIBRE,
  21.         self::SYSTEM_PRIMARY,
  22.     ];
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     private ?int $id null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $name null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $abreviation null;
  31.     #[ORM\Column]
  32.     private ?int $level null;
  33.     #[ORM\OneToMany(mappedBy'classLevel'targetEntityTheClass::class)]
  34.     private Collection $classes;
  35.     #[ORM\ManyToOne(inversedBy'classLevels')]
  36.     #[ORM\JoinColumn(nullablefalse)]
  37.     private ?CycleLevel $cycle null;
  38.     #[ORM\OneToMany(mappedBy'level'targetEntityClassOption::class, orphanRemovaltrue)]
  39.     private Collection $classOptions;
  40.     // Système d'évaluation par défaut proposé (et pré-coché) aux écoles qui créent
  41.     // une classe sur ce niveau — voir TheClassEvaluationSystem pour le choix réel,
  42.     // par classe et par année scolaire, qui peut différer de ce défaut.
  43.     #[ORM\Column(length20)]
  44.     private string $defaultEvaluationSystem self::SYSTEM_SEQUENCE;
  45.     public function __construct()
  46.     {
  47.         $this->classes = new ArrayCollection();
  48.         $this->classOptions = new ArrayCollection();
  49.     }
  50.     
  51.     public function __toString(): string
  52.     {
  53.         return $this->abreviation $this->name ' (' $this->abreviation ')' : (string) $this->name;
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getName(): ?string
  60.     {
  61.         return $this->name;
  62.     }
  63.     public function setName(string $name): static
  64.     {
  65.         $this->name $name;
  66.         return $this;
  67.     }
  68.     public function getAbreviation(): ?string
  69.     {
  70.         return $this->abreviation;
  71.     }
  72.     public function setAbreviation(?string $abreviation): static
  73.     {
  74.         $this->abreviation $abreviation;
  75.         return $this;
  76.     }
  77.     public function getLevel(): ?int
  78.     {
  79.         return $this->level;
  80.     }
  81.     public function setLevel(int $level): static
  82.     {
  83.         $this->level $level;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection<int, TheClass>
  88.      */
  89.     public function getClasses(): Collection
  90.     {
  91.         return $this->classes;
  92.     }
  93.     public function addClass(TheClass $class): static
  94.     {
  95.         if (!$this->classes->contains($class)) {
  96.             $this->classes->add($class);
  97.             $class->setClassLevel($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeClass(TheClass $class): static
  102.     {
  103.         if ($this->classes->removeElement($class)) {
  104.             // set the owning side to null (unless already changed)
  105.             if ($class->getClassLevel() === $this) {
  106.                 $class->setClassLevel(null);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111.     public function getDefaultEvaluationSystem(): string
  112.     {
  113.         return $this->defaultEvaluationSystem;
  114.     }
  115.     public function setDefaultEvaluationSystem(string $defaultEvaluationSystem): static
  116.     {
  117.         $this->defaultEvaluationSystem $defaultEvaluationSystem;
  118.         return $this;
  119.     }
  120.     public function getCycle(): ?CycleLevel
  121.     {
  122.         return $this->cycle;
  123.     }
  124.     public function setCycle(?CycleLevel $cycle): static
  125.     {
  126.         $this->cycle $cycle;
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return Collection<int, ClassOption>
  131.      */
  132.     public function getClassOptions(): Collection
  133.     {
  134.         return $this->classOptions;
  135.     }
  136.     public function addClassOption(ClassOption $classOption): static
  137.     {
  138.         if (!$this->classOptions->contains($classOption)) {
  139.             $this->classOptions->add($classOption);
  140.             $classOption->setLevel($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeClassOption(ClassOption $classOption): static
  145.     {
  146.         if ($this->classOptions->removeElement($classOption)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($classOption->getLevel() === $this) {
  149.                 $classOption->setLevel(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }