src/Entity/SubjectModule.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubjectModuleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\Timestampable;
  8. /**
  9.  * Thème (Module) LOCAL d'une matière dans un établissement.
  10.  *
  11.  * Pendant de Module (programme national) pour la partie du cahier de texte
  12.  * "hors programme national" : l'admin/éditeur d'une école peut créer ses
  13.  * propres thèmes pour regrouper ses SubjectLesson, exactement comme le
  14.  * superadmin le fait pour Lesson via Module — mais scopé au Subject réel
  15.  * (matière + classe + année + école), comme SubjectLesson, et non au
  16.  * SubjectReference (matière + ClassOption) qui est partagé entre écoles.
  17.  *
  18.  * Une SubjectLesson peut alternativement être rattachée directement à un
  19.  * Module national (voir SubjectLesson::$module) sans passer par un
  20.  * SubjectModule local — les deux mécanismes cohabitent.
  21.  */
  22. #[ORM\HasLifecycleCallbacks]
  23. #[ORM\Entity(repositoryClassSubjectModuleRepository::class)]
  24. class SubjectModule
  25. {
  26.     use Timestampable;
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     private ?int $id null;
  31.     #[ORM\Column(length255)]
  32.     private ?string $title null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $titleEn null;
  35.     /**
  36.      * Ordre d'affichage parmi les thèmes locaux de la matière (1, 2, 3...).
  37.      */
  38.     #[ORM\Column]
  39.     private ?int $position null;
  40.     #[ORM\ManyToOne(inversedBy'subjectModules')]
  41.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  42.     private ?Subject $subject null;
  43.     #[ORM\OneToMany(mappedBy'subjectModule'targetEntitySubjectLearningUnit::class)]
  44.     #[ORM\OrderBy(['position' => 'ASC'])]
  45.     private Collection $subjectLearningUnits;
  46.     #[ORM\OneToMany(mappedBy'subjectModule'targetEntitySubjectLesson::class)]
  47.     private Collection $subjectLessons;
  48.     #[ORM\ManyToOne]
  49.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  50.     private ?User $author null;
  51.     public function __construct()
  52.     {
  53.         $this->subjectLearningUnits = new ArrayCollection();
  54.         $this->subjectLessons = new ArrayCollection();
  55.     }
  56.     public function __toString(): string
  57.     {
  58.         return $this->title ?? '';
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getTitle(): ?string
  65.     {
  66.         return $this->title;
  67.     }
  68.     public function setTitle(string $title): static
  69.     {
  70.         $this->title $title;
  71.         return $this;
  72.     }
  73.     public function getTitleEn(): ?string
  74.     {
  75.         return $this->titleEn;
  76.     }
  77.     public function setTitleEn(?string $titleEn): static
  78.     {
  79.         $this->titleEn $titleEn;
  80.         return $this;
  81.     }
  82.     public function getPosition(): ?int
  83.     {
  84.         return $this->position;
  85.     }
  86.     public function setPosition(int $position): static
  87.     {
  88.         $this->position $position;
  89.         return $this;
  90.     }
  91.     public function getSubject(): ?Subject
  92.     {
  93.         return $this->subject;
  94.     }
  95.     public function setSubject(?Subject $subject): static
  96.     {
  97.         $this->subject $subject;
  98.         return $this;
  99.     }
  100.     /** @return Collection<int, SubjectLearningUnit> */
  101.     public function getSubjectLearningUnits(): Collection
  102.     {
  103.         return $this->subjectLearningUnits;
  104.     }
  105.     /** @return Collection<int, SubjectLesson> */
  106.     public function getSubjectLessons(): Collection
  107.     {
  108.         return $this->subjectLessons;
  109.     }
  110.     public function getAuthor(): ?User
  111.     {
  112.         return $this->author;
  113.     }
  114.     public function setAuthor(?User $author): static
  115.     {
  116.         $this->author $author;
  117.         return $this;
  118.     }
  119. }