src/Entity/StudentYear.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StudentYearRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use App\Entity\Traits\Timestampable;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  11. use JMS\Serializer\Annotation\Groups;
  12. #[ORM\HasLifecycleCallbacks]
  13. #[Vich\Uploadable]
  14. #[ORM\Entity(repositoryClassStudentYearRepository::class)]
  15. class StudentYear
  16. {
  17.     use Timestampable;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     #[Groups(['getStudents'])]
  22.     private ?int $id null;
  23.     #[ORM\ManyToOne(inversedBy'studentYears'cascade: ["persist"])]
  24.     #[Groups(['getStudents'])]
  25.     private ?SchoolYear $year null;
  26.     #[ORM\ManyToOne(inversedBy'studentYears'cascade: ["persist"])]
  27.     #[Groups(['getStudents','getExamStudent'])]
  28.     private ?Student $student null;
  29.   /**
  30.     * NOTE: This is not a mapped field of entity metadata, just a simple property.
  31.     *
  32.    */
  33.    #[Vich\UploadableField(mapping'student_profile'fileNameProperty'imageName')]
  34.    private ?File $imageFile null;
  35.    #[ORM\Column(length255nullabletrue)]
  36.    private ?string $imageName null;
  37.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'studentYears')]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     #[Groups(['getStudents','getExamStudent'])]
  40.     private ?TheClass $classe null;
  41.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'studentYears')]
  42.     #[Groups(['getStudents'])]
  43.     private ?School $school null;
  44.     #[ORM\OneToMany(mappedBy'student'targetEntityStudentScolarity::class)]
  45.     private Collection $studentScolarities;
  46.     /**
  47.      * Matières dont cet élève est dispensé pour cette inscription (classe + année).
  48.      *
  49.      * @var Collection<int, StudentSubjectExemption>
  50.      */
  51.     #[ORM\OneToMany(mappedBy'studentYear'targetEntityStudentSubjectExemption::class, orphanRemovaltrue)]
  52.     private Collection $subjectExemptions;
  53.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'students')]
  54.     private ?Scolarity $scolarity null;
  55.     #[ORM\OneToMany(mappedBy'student'targetEntityScolarityHistory::class)]
  56.     private Collection $scolarityHistories;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     private ?string $slug null;
  59.     #[ORM\Column(length255nullabletrue)]
  60.     private ?string $lastSchoolName null;
  61.     #[ORM\Column(nullabletrue)]
  62.     private ?bool $repeater null;
  63.     #[ORM\Column(type'boolean'options: ['default' => true])]
  64.     private ?bool $active null;
  65.     public function __construct()
  66.     {
  67.         $this->active true;
  68.         $this->studentScolarities = new ArrayCollection();
  69.         $this->scolarityHistories = new ArrayCollection();
  70.         $this->subjectExemptions = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getYear(): ?SchoolYear
  77.     {
  78.         return $this->year;
  79.     }
  80.     public function setYear(?SchoolYear $year): static
  81.     {
  82.         $this->year $year;
  83.         return $this;
  84.     }
  85.     public function getStudent(): ?Student
  86.     {
  87.         return $this->student;
  88.     }
  89.     public function setStudent(?Student $student): static
  90.     {
  91.         $this->student $student;
  92.         return $this;
  93.     }
  94.     public function getClasse(): ?TheClass
  95.     {
  96.         return $this->classe;
  97.     }
  98.     public function setClasse(?TheClass $classe): static
  99.     {
  100.         $this->classe $classe;
  101.         return $this;
  102.     }
  103.     /**
  104.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  105.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  106.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  107.      * must be able to accept an instance of 'File' as the bundle will inject one here
  108.      * during Doctrine hydration.
  109.      *
  110.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  111.      */
  112.     public function setImageFile(?File $imageFile null): void
  113.     {
  114.         $this->imageFile $imageFile;
  115.         if (null !== $imageFile) {
  116.             // It is required that at least one field changes if you are using doctrine
  117.             // otherwise the event listeners won't be called and the file is lost
  118.             $this->setUpdatedAt(new \DateTime());
  119.         }
  120.     }
  121.     public function getImageFile(): ?File
  122.     {
  123.         return $this->imageFile;
  124.     }
  125.     public function getImageName(): ?string
  126.     {
  127.         return $this->imageName;
  128.     }
  129.     public function setImageName(?string $imageName): static
  130.     {
  131.         $this->imageName $imageName;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return Collection<int, StudentScolarity>
  136.      */
  137.     public function getStudentScolarities(): Collection
  138.     {
  139.         return $this->studentScolarities;
  140.     }
  141.     public function addStudentScolarity(StudentScolarity $studentScolarity): static
  142.     {
  143.         if (!$this->studentScolarities->contains($studentScolarity)) {
  144.             $this->studentScolarities->add($studentScolarity);
  145.             $studentScolarity->setStudent($this);
  146.         }
  147.         return $this;
  148.     }
  149.     public function removeStudentScolarity(StudentScolarity $studentScolarity): static
  150.     {
  151.         if ($this->studentScolarities->removeElement($studentScolarity)) {
  152.             // set the owning side to null (unless already changed)
  153.             if ($studentScolarity->getStudent() === $this) {
  154.                 $studentScolarity->setStudent(null);
  155.             }
  156.         }
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, StudentSubjectExemption>
  161.      */
  162.     public function getSubjectExemptions(): Collection
  163.     {
  164.         return $this->subjectExemptions;
  165.     }
  166.     public function addSubjectExemption(StudentSubjectExemption $subjectExemption): static
  167.     {
  168.         if (!$this->subjectExemptions->contains($subjectExemption)) {
  169.             $this->subjectExemptions->add($subjectExemption);
  170.             $subjectExemption->setStudentYear($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeSubjectExemption(StudentSubjectExemption $subjectExemption): static
  175.     {
  176.         if ($this->subjectExemptions->removeElement($subjectExemption)) {
  177.             if ($subjectExemption->getStudentYear() === $this) {
  178.                 $subjectExemption->setStudentYear(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     public function getScolarity(): ?Scolarity
  184.     {
  185.         return $this->scolarity;
  186.     }
  187.     public function setScolarity(?Scolarity $scolarity): static
  188.     {
  189.         $this->scolarity $scolarity;
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return Collection<int, ScolarityHystory>
  194.      */
  195.     public function getScolarityHistories(): Collection
  196.     {
  197.         return $this->scolarityHistories;
  198.     }
  199.     public function addScolarityHistory(ScolarityHistory $scolarityHistory): static
  200.     {
  201.         if (!$this->scolarityHistories->contains($scolarityHistory)) {
  202.             $this->scolarityHistories->add($scolarityHistory);
  203.             $scolarityHistory->setStudent($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeScolarityHistory(ScolarityHistory $scolarityHistory): static
  208.     {
  209.         if ($this->scolarityHistories->removeElement($scolarityHistory)) {
  210.             // set the owning side to null (unless already changed)
  211.             if ($scolarityHistory->getStudent() === $this) {
  212.                 $scolarityHistory->setStudent(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217.     public function getSchool(): ?School
  218.     {
  219.         return $this->school;
  220.     }
  221.     public function setSchool(?School $school): static
  222.     {
  223.         $this->school $school;
  224.         return $this;
  225.     }
  226.     public function getSlug(): ?string
  227.     {
  228.         return $this->slug;
  229.     }
  230.     public function setSlug(?string $slug): static
  231.     {
  232.         $this->slug $slug;
  233.         return $this;
  234.     }
  235.     public function getLastSchoolName(): ?string
  236.     {
  237.         return $this->lastSchoolName;
  238.     }
  239.     public function setLastSchoolName(?string $lastSchoolName): static
  240.     {
  241.         $this->lastSchoolName $lastSchoolName;
  242.         return $this;
  243.     }
  244.     public function isRepeater(): ?bool
  245.     {
  246.         return $this->repeater;
  247.     }
  248.     public function setRepeater(?bool $repeater): static
  249.     {
  250.         $this->repeater $repeater;
  251.         return $this;
  252.     }
  253.     public function isActive(): ?bool
  254.     {
  255.         return $this->active;
  256.     }
  257.     public function setActive(bool $active): static
  258.     {
  259.         $this->active $active;
  260.         return $this;
  261.     }
  262. }