src/Entity/Subject.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubjectRepository;
  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. use JMS\Serializer\Annotation\Groups;
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Entity(repositoryClassSubjectRepository::class)]
  11. class Subject
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     #[Groups(['getAbsence','homework','note','getBulletin''getAgenda''getExamAgenda'])]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     #[Groups(['getAbsence','homework','note','getBulletin','getDiscussion''getAgenda''getExamAgenda'])]
  21.     private ?string $name null;
  22.     #[ORM\Column]
  23.     #[Groups(['getBulletin','getSubject'])]
  24.     private ?float $coef null;
  25.     /**
  26.      * Horaire hebdomadaire (nombre d'heures de cours par semaine), facultatif.
  27.      */
  28.     #[ORM\Column(nullabletrue)]
  29.     #[Groups(['getSubject'])]
  30.     private ?float $horaire null;
  31.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  32.     #[Groups(["getSubject"])]
  33.     private ?TheClass $classe null;
  34.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  35.     #[Groups(["getSubject"])]
  36.     private ?User $prof null;
  37.     #[ORM\Column]
  38.     private ?bool $active null;
  39.     #[ORM\OneToMany(mappedBy'subject'targetEntityHomeWork::class)]
  40.     private Collection $homeWorks;
  41.     #[ORM\OneToMany(mappedBy'subject'targetEntityAbsence::class)]
  42.     private Collection $absences;
  43.     /**
  44.      * Cahier de texte : entrées (avec ou sans leçon du programme
  45.      * national) saisies par le prof pour cette matière réelle.
  46.      */
  47.     #[ORM\OneToMany(mappedBy'subject'targetEntityLessonLog::class, cascade: ['remove'], orphanRemovaltrue)]
  48.     #[ORM\OrderBy(['date' => 'DESC'])]
  49.     private Collection $lessonLogs;
  50.     #[ORM\ManyToOne(inversedBy'subjects'cascade: ["persist"])]
  51.     #[ORM\JoinColumn(nullablefalse)]
  52.     private ?SubjectGroup $subjectGroup null;
  53.     #[ORM\OneToMany(mappedBy'subject'targetEntityNote::class)]
  54.     private Collection $notes;
  55.     #[ORM\OneToMany(mappedBy'subject'targetEntityExams::class)]
  56.     private Collection $exams;
  57.     #[ORM\ManyToOne(inversedBy'subjectsEdited'cascade: ["persist"])]
  58.     private ?User $editor null;
  59.     #[ORM\ManyToOne(inversedBy'subjectsCreated'cascade: ["persist"])]
  60.     private ?User $author null;
  61.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  62.     #[Groups(['getSubject'])]
  63.     private ?School $school null;
  64.     #[ORM\OneToMany(mappedBy'subject'targetEntityAgendaElement::class)]
  65.     private Collection $agendaElements;
  66.     #[ORM\OneToMany(mappedBy'subject'targetEntityExamAgendaElement::class)]
  67.     private Collection $examAgendaElements;
  68.     #[Groups(['getAbsence','homework','note','getBulletin','getDiscussion''getAgenda''getExamAgenda'])]
  69.     #[ORM\Column(length255nullabletrue)]
  70.     private ?string $competence null;
  71.     #[ORM\OneToMany(mappedBy'subject'targetEntityParentNote::class)]
  72.     private Collection $parentNotes;
  73.     #[ORM\ManyToOne(inversedBy'subjects')]
  74.     private ?SchoolYear $year null;
  75.     #[ORM\OneToOne(mappedBy'subject'cascade: ['persist''remove'])]
  76.     private ?PrimaryParentNote $primaryParentNote null;
  77.     #[ORM\OneToMany(mappedBy'subject'targetEntityPrimaryNote::class)]
  78.     private Collection $primaryNotes;
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?float $point null;
  81.     #[ORM\Column(nullabletrue)]
  82.     private ?float $totalPoints null;
  83.     #[ORM\OneToMany(mappedBy'subject'targetEntitySubNote::class, orphanRemovaltrue)]
  84.     private Collection $subNotes;
  85.     #[ORM\OneToMany(mappedBy'subject'targetEntityCompetence::class, cascade: ["persist""remove"], orphanRemovaltrue)]
  86.     private Collection $competences;
  87.     #[ORM\OneToMany(mappedBy'subject'targetEntityWeekSubjectGoal::class)]
  88.     private Collection $weekSubjectGoals;
  89.     #[ORM\OneToMany(mappedBy'subject'targetEntityProfSchoolPlanner::class)]
  90.     private Collection $profSchoolPlanners;
  91.     #[ORM\Column(nullabletrue)]
  92.     private ?float $longitude null;
  93.     #[ORM\Column(nullabletrue)]
  94.     private ?float $latitude null;
  95.     #[ORM\OneToMany(mappedBy'subject'targetEntityProfTime::class)]
  96.     private Collection $profTimes;
  97.     /**
  98.      * Progression des leçons du programme national pour ce Subject
  99.      * réel (matière + classe + école + année). 1 entrée par Lesson.
  100.      */
  101.     #[ORM\OneToMany(mappedBy'subject'targetEntityLessonProgress::class, orphanRemovaltrue)]
  102.     private Collection $lessonProgresses;
  103.     #[ORM\ManyToOne(inversedBy'subjects')]
  104.     private ?SubjectReference $reference null;
  105.     public function __toString():string
  106.     {
  107.         return $this->name;
  108.     }
  109.     public function __construct()
  110.     {
  111.         $this->homeWorks = new ArrayCollection();
  112.         $this->absences = new ArrayCollection();
  113.         $this->lessonLogs = new ArrayCollection();
  114.         $this->notes = new ArrayCollection();
  115.         $this->exams = new ArrayCollection();
  116.         $this->agendaElements = new ArrayCollection();
  117.         $this->examAgendaElements = new ArrayCollection();
  118.         $this->parentNotes = new ArrayCollection();
  119.         $this->primaryNotes = new ArrayCollection();
  120.         $this->subNotes = new ArrayCollection();
  121.         $this->competences = new ArrayCollection();
  122.         $this->weekSubjectGoals = new ArrayCollection();
  123.         $this->profSchoolPlanners = new ArrayCollection();
  124.         $this->profTimes = new ArrayCollection();
  125.         $this->lessonProgresses = new ArrayCollection();
  126.     }
  127.     public function getId(): ?int
  128.     {
  129.         return $this->id;
  130.     }
  131.     public function getName(): ?string
  132.     {
  133.         return $this->name;
  134.     }
  135.     public function setName(string $name): static
  136.     {
  137.         $this->name $name;
  138.         return $this;
  139.     }
  140.     public function getCoef(): ?float
  141.     {
  142.         return $this->coef;
  143.     }
  144.     public function setCoef(float $coef): static
  145.     {
  146.         $this->coef $coef;
  147.         return $this;
  148.     }
  149.     public function getHoraire(): ?float
  150.     {
  151.         return $this->horaire;
  152.     }
  153.     public function setHoraire(?float $horaire): static
  154.     {
  155.         $this->horaire $horaire;
  156.         return $this;
  157.     }
  158.     public function getClasse(): ?TheClass
  159.     {
  160.         return $this->classe;
  161.     }
  162.     public function setClasse(?TheClass $classe): static
  163.     {
  164.         $this->classe $classe;
  165.         return $this;
  166.     }
  167.     public function getProf(): ?User
  168.     {
  169.         return $this->prof;
  170.     }
  171.     public function setProf(?User $prof): static
  172.     {
  173.         $this->prof $prof;
  174.         return $this;
  175.     }
  176.     public function isActive(): ?bool
  177.     {
  178.         return $this->active;
  179.     }
  180.     public function setActive(bool $active): static
  181.     {
  182.         $this->active $active;
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return Collection<int, HomeWork>
  187.      */
  188.     public function getHomeWorks(): Collection
  189.     {
  190.         return $this->homeWorks;
  191.     }
  192.     public function addHomeWork(HomeWork $homeWork): static
  193.     {
  194.         if (!$this->homeWorks->contains($homeWork)) {
  195.             $this->homeWorks->add($homeWork);
  196.             $homeWork->setSubject($this);
  197.         }
  198.         return $this;
  199.     }
  200.     public function removeHomeWork(HomeWork $homeWork): static
  201.     {
  202.         if ($this->homeWorks->removeElement($homeWork)) {
  203.             // set the owning side to null (unless already changed)
  204.             if ($homeWork->getSubject() === $this) {
  205.                 $homeWork->setSubject(null);
  206.             }
  207.         }
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection<int, Absence>
  212.      */
  213.     public function getAbsences(): Collection
  214.     {
  215.         return $this->absences;
  216.     }
  217.     public function addAbsence(Absence $absence): static
  218.     {
  219.         if (!$this->absences->contains($absence)) {
  220.             $this->absences->add($absence);
  221.             $absence->setSubject($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeAbsence(Absence $absence): static
  226.     {
  227.         if ($this->absences->removeElement($absence)) {
  228.             // set the owning side to null (unless already changed)
  229.             if ($absence->getSubject() === $this) {
  230.                 $absence->setSubject(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection<int, LessonLog>
  237.      */
  238.     public function getLessonLogs(): Collection
  239.     {
  240.         return $this->lessonLogs;
  241.     }
  242.     public function addLessonLog(LessonLog $lessonLog): static
  243.     {
  244.         if (!$this->lessonLogs->contains($lessonLog)) {
  245.             $this->lessonLogs->add($lessonLog);
  246.             $lessonLog->setSubject($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeLessonLog(LessonLog $lessonLog): static
  251.     {
  252.         if ($this->lessonLogs->removeElement($lessonLog)) {
  253.             if ($lessonLog->getSubject() === $this) {
  254.                 $lessonLog->setSubject(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     public function getSubjectGroup(): ?SubjectGroup
  260.     {
  261.         return $this->subjectGroup;
  262.     }
  263.     public function setSubjectGroup(?SubjectGroup $subjectGroup): static
  264.     {
  265.         $this->subjectGroup $subjectGroup;
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, Note>
  270.      */
  271.     public function getNotes(): Collection
  272.     {
  273.         return $this->notes;
  274.     }
  275.     public function addNote(Note $note): static
  276.     {
  277.         if (!$this->notes->contains($note)) {
  278.             $this->notes->add($note);
  279.             $note->setSubject($this);
  280.         }
  281.         return $this;
  282.     }
  283.     public function removeNote(Note $note): static
  284.     {
  285.         if ($this->notes->removeElement($note)) {
  286.             // set the owning side to null (unless already changed)
  287.             if ($note->getSubject() === $this) {
  288.                 $note->setSubject(null);
  289.             }
  290.         }
  291.         return $this;
  292.     }
  293.     /**
  294.      * @return Collection<int, Exams>
  295.      */
  296.     public function getExams(): Collection
  297.     {
  298.         return $this->exams;
  299.     }
  300.     public function addExam(Exams $exam): static
  301.     {
  302.         if (!$this->exams->contains($exam)) {
  303.             $this->exams->add($exam);
  304.             $exam->setSubject($this);
  305.         }
  306.         return $this;
  307.     }
  308.     public function removeExam(Exams $exam): static
  309.     {
  310.         if ($this->exams->removeElement($exam)) {
  311.             // set the owning side to null (unless already changed)
  312.             if ($exam->getSubject() === $this) {
  313.                 $exam->setSubject(null);
  314.             }
  315.         }
  316.         return $this;
  317.     }
  318.     public function getEditor(): ?User
  319.     {
  320.         return $this->editor;
  321.     }
  322.     public function setEditor(?User $editor): static
  323.     {
  324.         $this->editor $editor;
  325.         return $this;
  326.     }
  327.     public function getAuthor(): ?User
  328.     {
  329.         return $this->author;
  330.     }
  331.     public function setAuthor(?User $author): static
  332.     {
  333.         $this->author $author;
  334.         return $this;
  335.     }
  336.     public function getSchool(): ?School
  337.     {
  338.         return $this->school;
  339.     }
  340.     public function setSchool(?School $school): static
  341.     {
  342.         $this->school $school;
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, AgendaElement>
  347.      */
  348.     public function getAgendaElements(): Collection
  349.     {
  350.         return $this->agendaElements;
  351.     }
  352.     public function addAgendaElement(AgendaElement $agendaElement): static
  353.     {
  354.         if (!$this->agendaElements->contains($agendaElement)) {
  355.             $this->agendaElements->add($agendaElement);
  356.             $agendaElement->setSubject($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeAgendaElement(AgendaElement $agendaElement): static
  361.     {
  362.         if ($this->agendaElements->removeElement($agendaElement)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($agendaElement->getSubject() === $this) {
  365.                 $agendaElement->setSubject(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection<int, ExamAgendaElement>
  372.      */
  373.     public function getExamAgendaElements(): Collection
  374.     {
  375.         return $this->examAgendaElements;
  376.     }
  377.     public function addExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  378.     {
  379.         if (!$this->examAgendaElements->contains($examAgendaElement)) {
  380.             $this->examAgendaElements->add($examAgendaElement);
  381.             $examAgendaElement->setSubject($this);
  382.         }
  383.         return $this;
  384.     }
  385.     public function removeExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  386.     {
  387.         if ($this->examAgendaElements->removeElement($examAgendaElement)) {
  388.             // set the owning side to null (unless already changed)
  389.             if ($examAgendaElement->getSubject() === $this) {
  390.                 $examAgendaElement->setSubject(null);
  391.             }
  392.         }
  393.         return $this;
  394.     }
  395.     public function getCompetence(): ?string
  396.     {
  397.         return $this->competence;
  398.     }
  399.     public function setCompetence(?string $competence): static
  400.     {
  401.         $this->competence $competence;
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return Collection<int, ParentNote>
  406.      */
  407.     public function getParentNotes(): Collection
  408.     {
  409.         return $this->parentNotes;
  410.     }
  411.     public function addParentNote(ParentNote $parentNote): static
  412.     {
  413.         if (!$this->parentNotes->contains($parentNote)) {
  414.             $this->parentNotes->add($parentNote);
  415.             $parentNote->setSubject($this);
  416.         }
  417.         return $this;
  418.     }
  419.     /* 
  420.         @return Collection<int, SubNote>
  421.      */
  422.     public function getSubNotes(): Collection
  423.     {
  424.         return $this->subNotes;
  425.     }
  426.     public function addSubNote(SubNote $subNote): static
  427.     {
  428.         if (!$this->subNotes->contains($subNote)) {
  429.             $this->subNotes->add($subNote);
  430.             $subNote->setSubject($this);
  431.         }
  432.         return $this;
  433.     }
  434.     public function removeParentNote(ParentNote $parentNote): static
  435.     {
  436.         if ($this->parentNotes->removeElement($parentNote)) {
  437.             // set the owning side to null (unless already changed)
  438.             if ($parentNote->getSubject() === $this) {
  439.                 $parentNote->setSubject(null);
  440.             }
  441.         }
  442.         return $this;
  443.     }
  444.     public function removeSubNote(SubNote $subNote): static
  445.     {
  446.         if ($this->subNotes->removeElement($subNote)) {
  447.             // set the owning side to null (unless already changed)
  448.             if ($subNote->getSubject() === $this) {
  449.                 $subNote->setSubject(null);
  450.             }
  451.         }
  452.         return $this;
  453.     }
  454.     public function getYear(): ?SchoolYear
  455.     {
  456.         return $this->year;
  457.     }
  458.     public function setYear(?SchoolYear $year): static
  459.     {
  460.         $this->year $year;
  461.         return $this;
  462.     }
  463.     public function getPrimaryParentNote(): ?PrimaryParentNote
  464.     {
  465.         return $this->primaryParentNote;
  466.     }
  467.     public function setPrimaryParentNote(PrimaryParentNote $primaryParentNote): static
  468.     {
  469.         // set the owning side of the relation if necessary
  470.         if ($primaryParentNote->getSubject() !== $this) {
  471.             $primaryParentNote->setSubject($this);
  472.         }
  473.         $this->primaryParentNote $primaryParentNote;
  474.         return $this;
  475.     }
  476.     /**
  477.      * @return Collection<int, PrimaryNote>
  478.      */
  479.     public function getPrimaryNotes(): Collection
  480.     {
  481.         return $this->primaryNotes;
  482.     }
  483.     public function addPrimaryNote(PrimaryNote $primaryNote): static
  484.     {
  485.         if (!$this->primaryNotes->contains($primaryNote)) {
  486.             $this->primaryNotes->add($primaryNote);
  487.             $primaryNote->setSubject($this);
  488.         }
  489.         return $this;
  490.     }
  491.     public function removePrimaryNote(PrimaryNote $primaryNote): static
  492.     {
  493.         if ($this->primaryNotes->removeElement($primaryNote)) {
  494.             // set the owning side to null (unless already changed)
  495.             if ($primaryNote->getSubject() === $this) {
  496.                 $primaryNote->setSubject(null);
  497.             }
  498.         }
  499.         return $this;
  500.     }
  501.     public function getPoint(): ?float
  502.     {
  503.         return $this->point;
  504.     }
  505.     public function setPoint(?float $point): static
  506.     {
  507.         $this->point $point;
  508.         return $this;
  509.     }
  510.     public function getTotalPoints(): ?float
  511.     {
  512.         return $this->totalPoints;
  513.     }
  514.     public function setTotalPoints(?float $totalPoints): static
  515.     {
  516.         $this->totalPoints $totalPoints;
  517.         return $this;
  518.     }
  519.     /**
  520.      * @return Collection<int, Competence>
  521.      */
  522.     public function getCompetences(): Collection
  523.     {
  524.         return $this->competences;
  525.     }
  526.     public function addCompetence(Competence $competence): static
  527.     {
  528.         if (!$this->competences->contains($competence)) {
  529.             $this->competences->add($competence);
  530.             $competence->setSubject($this);
  531.         }
  532.         return $this;
  533.     }
  534.     public function removeCompetence(Competence $competence): static
  535.     {
  536.         if ($this->competences->removeElement($competence)) {
  537.             // set the owning side to null (unless already changed)
  538.             if ($competence->getSubject() === $this) {
  539.                 $competence->setSubject(null);
  540.             }
  541.         }
  542.         return $this;
  543.     }
  544.     /**
  545.      * @return Collection<int, WeekSubjectGoal>
  546.      */
  547.     public function getWeekSubjectGoals(): Collection
  548.     {
  549.         return $this->weekSubjectGoals;
  550.     }
  551.     public function addWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
  552.     {
  553.         if (!$this->weekSubjectGoals->contains($weekSubjectGoal)) {
  554.             $this->weekSubjectGoals->add($weekSubjectGoal);
  555.             $weekSubjectGoal->setSubject($this);
  556.         }
  557.         return $this;
  558.     }
  559.     public function removeWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
  560.     {
  561.         if ($this->weekSubjectGoals->removeElement($weekSubjectGoal)) {
  562.             // set the owning side to null (unless already changed)
  563.             if ($weekSubjectGoal->getSubject() === $this) {
  564.                 $weekSubjectGoal->setSubject(null);
  565.             }
  566.         }
  567.         return $this;
  568.     }
  569.     /**
  570.      * @return Collection<int, ProfSchoolPlanner>
  571.      */
  572.     public function getProfSchoolPlanners(): Collection
  573.     {
  574.         return $this->profSchoolPlanners;
  575.     }
  576.     public function addProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
  577.     {
  578.         if (!$this->profSchoolPlanners->contains($profSchoolPlanner)) {
  579.             $this->profSchoolPlanners->add($profSchoolPlanner);
  580.             $profSchoolPlanner->setSubject($this);
  581.         }
  582.         return $this;
  583.     }
  584.     public function removeProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
  585.     {
  586.         if ($this->profSchoolPlanners->removeElement($profSchoolPlanner)) {
  587.             // set the owning side to null (unless already changed)
  588.             if ($profSchoolPlanner->getSubject() === $this) {
  589.                 $profSchoolPlanner->setSubject(null);
  590.             }
  591.         }
  592.         return $this;
  593.     }
  594.     public function getLongitude(): ?float
  595.     {
  596.         return $this->longitude;
  597.     }
  598.     public function setLongitude(?float $longitude): static
  599.     {
  600.         $this->longitude $longitude;
  601.         return $this;
  602.     }
  603.     public function getLatitude(): ?float
  604.     {
  605.         return $this->latitude;
  606.     }
  607.     public function setLatitude(?float $latitude): static
  608.     {
  609.         $this->latitude $latitude;
  610.         return $this;
  611.     }
  612.     /**
  613.      * @return Collection<int, ProfTime>
  614.      */
  615.     public function getProfTimes(): Collection
  616.     {
  617.         return $this->profTimes;
  618.     }
  619.     public function addProfTime(ProfTime $profTime): static
  620.     {
  621.         if (!$this->profTimes->contains($profTime)) {
  622.             $this->profTimes->add($profTime);
  623.             $profTime->setSubject($this);
  624.         }
  625.         return $this;
  626.     }
  627.     public function removeProfTime(ProfTime $profTime): static
  628.     {
  629.         if ($this->profTimes->removeElement($profTime)) {
  630.             // set the owning side to null (unless already changed)
  631.             if ($profTime->getSubject() === $this) {
  632.                 $profTime->setSubject(null);
  633.             }
  634.         }
  635.         return $this;
  636.     }
  637.     /**
  638.      * @return Collection<int, LessonProgress>
  639.      */
  640.     public function getLessonProgresses(): Collection
  641.     {
  642.         return $this->lessonProgresses;
  643.     }
  644.     public function addLessonProgress(LessonProgress $lessonProgress): static
  645.     {
  646.         if (!$this->lessonProgresses->contains($lessonProgress)) {
  647.             $this->lessonProgresses->add($lessonProgress);
  648.             $lessonProgress->setSubject($this);
  649.         }
  650.         return $this;
  651.     }
  652.     public function removeLessonProgress(LessonProgress $lessonProgress): static
  653.     {
  654.         if ($this->lessonProgresses->removeElement($lessonProgress)) {
  655.             if ($lessonProgress->getSubject() === $this) {
  656.                 $lessonProgress->setSubject(null);
  657.             }
  658.         }
  659.         return $this;
  660.     }
  661.     public function getReference(): ?SubjectReference
  662.     {
  663.         return $this->reference;
  664.     }
  665.     public function setReference(?SubjectReference $reference): static
  666.     {
  667.         $this->reference $reference;
  668.         return $this;
  669.     }
  670. }