src/Entity/LearningUnit.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LearningUnitRepository;
  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.  * Unité d'Apprentissage (UA) du programme national (créée par le superadmin).
  10.  *
  11.  * Niveau optionnel entre le Module (nullable — une UA peut exister sans
  12.  * Module parent, ex: matières sans Thème mais avec UA) et la Leçon (Lesson).
  13.  * `position` définit l'ordre d'apparition dans le programme.
  14.  */
  15. #[ORM\HasLifecycleCallbacks]
  16. #[ORM\Entity(repositoryClassLearningUnitRepository::class)]
  17. class LearningUnit
  18. {
  19.     use Timestampable;
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     private ?int $id null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $title null;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     private ?string $titleEn null;
  28.     #[ORM\Column]
  29.     private ?int $position null;
  30.     #[ORM\ManyToOne(inversedBy'learningUnits')]
  31.     #[ORM\JoinColumn(nullablefalse)]
  32.     private ?SubjectReference $subjectReference null;
  33.     #[ORM\ManyToOne(inversedBy'learningUnits')]
  34.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  35.     private ?Module $module null;
  36.     #[ORM\OneToMany(mappedBy'learningUnit'targetEntityLesson::class)]
  37.     private Collection $lessons;
  38.     #[ORM\ManyToOne]
  39.     private ?User $author null;
  40.     public function __construct()
  41.     {
  42.         $this->lessons = new ArrayCollection();
  43.     }
  44.     public function __toString(): string
  45.     {
  46.         return $this->title ?? '';
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getTitle(): ?string
  53.     {
  54.         return $this->title;
  55.     }
  56.     public function setTitle(string $title): static
  57.     {
  58.         $this->title $title;
  59.         return $this;
  60.     }
  61.     public function getTitleEn(): ?string
  62.     {
  63.         return $this->titleEn;
  64.     }
  65.     public function setTitleEn(?string $titleEn): static
  66.     {
  67.         $this->titleEn $titleEn;
  68.         return $this;
  69.     }
  70.     public function getPosition(): ?int
  71.     {
  72.         return $this->position;
  73.     }
  74.     public function setPosition(int $position): static
  75.     {
  76.         $this->position $position;
  77.         return $this;
  78.     }
  79.     public function getSubjectReference(): ?SubjectReference
  80.     {
  81.         return $this->subjectReference;
  82.     }
  83.     public function setSubjectReference(?SubjectReference $subjectReference): static
  84.     {
  85.         $this->subjectReference $subjectReference;
  86.         return $this;
  87.     }
  88.     public function getModule(): ?Module
  89.     {
  90.         return $this->module;
  91.     }
  92.     public function setModule(?Module $module): static
  93.     {
  94.         $this->module $module;
  95.         return $this;
  96.     }
  97.     /** @return Collection<int, Lesson> */
  98.     public function getLessons(): Collection
  99.     {
  100.         return $this->lessons;
  101.     }
  102.     public function getAuthor(): ?User
  103.     {
  104.         return $this->author;
  105.     }
  106.     public function setAuthor(?User $author): static
  107.     {
  108.         $this->author $author;
  109.         return $this;
  110.     }
  111. }