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