src/Entity/Engagement.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EngagementRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassEngagementRepository::class)]
  9. class Engagement
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'engagements')]
  16.     #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
  17.     private ?User $formateur null;
  18.     #[ORM\ManyToOne(inversedBy'engagements')]
  19.     #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
  20.     private ?Module $module null;
  21.     #[ORM\ManyToOne(inversedBy'engagements')]
  22.     #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
  23.     private ?Cycle $cycle null;
  24.     #[ORM\OneToMany(mappedBy'engagement'targetEntityFactureFormateur::class)]
  25.     private Collection $factureFormateurs;
  26.     #[ORM\Column(length255)]
  27.     private ?string $groupe null;
  28.     #[ORM\ManyToOne(inversedBy:'engagements')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Session $session null;
  31.     #[ORM\OneToMany(mappedBy'engagement'targetEntitySeance::class)]
  32.     private Collection $seances;
  33.     public function __construct()
  34.     {
  35.         $this->factureFormateurs = new ArrayCollection();
  36.         $this->seances = new ArrayCollection();
  37.     }
  38.     public function __toString()
  39.     {
  40.         return 'Session: ' .
  41.             $this->getSession()->getLibele() .
  42.             ' - Cycle: ' .
  43.             $this->getCycle()->getLibele() .
  44.             ' - Formateur:' .
  45.             $this->getFormateur()->getUserIdentifier() .
  46.             ' - Module:' .
  47.             $this->getModule()->getLibele() .
  48.             ' - Groupe:' .
  49.             $this->getGroupe();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getFormateur(): ?User
  56.     {
  57.         return $this->formateur;
  58.     }
  59.     public function setFormateur(?User $formateur): self
  60.     {
  61.         $this->formateur $formateur;
  62.         return $this;
  63.     }
  64.     public function getModule(): ?Module
  65.     {
  66.         return $this->module;
  67.     }
  68.     public function setModule(?Module $module): self
  69.     {
  70.         $this->module $module;
  71.         return $this;
  72.     }
  73.     public function getCycle(): ?Cycle
  74.     {
  75.         return $this->cycle;
  76.     }
  77.     public function setCycle(?Cycle $cycle): self
  78.     {
  79.         $this->cycle $cycle;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, FactureFormateur>
  84.      */
  85.     public function getFactureFormateurs(): Collection
  86.     {
  87.         return $this->factureFormateurs;
  88.     }
  89.     public function addFactureFormateur(
  90.         FactureFormateur $factureFormateur
  91.     ): self {
  92.         if (!$this->factureFormateurs->contains($factureFormateur)) {
  93.             $this->factureFormateurs->add($factureFormateur);
  94.             $factureFormateur->setEngagement($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeFactureFormateur(
  99.         FactureFormateur $factureFormateur
  100.     ): self {
  101.         if ($this->factureFormateurs->removeElement($factureFormateur)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($factureFormateur->getEngagement() === $this) {
  104.                 $factureFormateur->setEngagement(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     public function getGroupe(): ?string
  110.     {
  111.         return $this->groupe;
  112.     }
  113.     public function setGroupe(?string $groupe): self
  114.     {
  115.         $this->groupe $groupe;
  116.         return $this;
  117.     }
  118.     public function getSession(): ?Session
  119.     {
  120.         return $this->session;
  121.     }
  122.     public function setSession(?Session $session): self
  123.     {
  124.         $this->session $session;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<int, Seance>
  129.      */
  130.     public function getSeances(): Collection
  131.     {
  132.         return $this->seances;
  133.     }
  134.     public function addSeance(Seance $seance): self
  135.     {
  136.         if (!$this->seances->contains($seance)) {
  137.             $this->seances->add($seance);
  138.             $seance->setEngagement($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeSeance(Seance $seance): self
  143.     {
  144.         if ($this->seances->removeElement($seance)) {
  145.             // set the owning side to null (unless already changed)
  146.             if ($seance->getEngagement() === $this) {
  147.                 $seance->setEngagement(null);
  148.             }
  149.         }
  150.         return $this;
  151.     }
  152. }