src/Entity/Gestiform/Formations/Session/SessionBlocModule.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Session;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Gestiform\Formations\Catalogue\Parcours\Bloc\BlocModule;
  5. use App\Entity\Gestiform\Formations\Session\Planning\Event;
  6. use App\Repository\Gestiform\Formations\Session\SessionBlocModuleRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use function Symfony\Component\Translation\t;
  11. /**
  12.  * @ORM\Entity(repositoryClass=SessionBlocModuleRepository::class)
  13.  */
  14. class SessionBlocModule extends AbstractEntity
  15. {
  16.     /**
  17.      * @ORM\Column(type="integer", nullable=true)
  18.      */
  19.     private ?int $duree null;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=Session::class, inversedBy="sessionBlocModules")
  22.      */
  23.     private Session $session;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=BlocModule::class, inversedBy="sessionBlocModules")
  26.      */
  27.     private BlocModule $blocModule;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=Event::class, mappedBy="sessionBlocModule")
  30.      */
  31.     private Collection $events;
  32.     public function __construct()
  33.     {
  34.         $this->events = new ArrayCollection();
  35.     }
  36.     public function getSession(): Session
  37.     {
  38.         return $this->session;
  39.     }
  40.     public function setSession(Session $session): self
  41.     {
  42.         $this->session $session;
  43.         return $this;
  44.     }
  45.     public function getBlocModule(): BlocModule
  46.     {
  47.         return $this->blocModule;
  48.     }
  49.     public function setBlocModule(BlocModule $blocModule): self
  50.     {
  51.         $this->blocModule $blocModule;
  52.         $this->setDuree($this->blocModule->getModule()->getDuree());
  53.         return $this;
  54.     }
  55.     public function getEvents(): Collection
  56.     {
  57.         return $this->events;
  58.     }
  59.     public function addEvent(Event $event): self
  60.     {
  61.         if (!$this->events->contains($event)) {
  62.             $this->events->add($event);
  63.             $event->setSessionBlocModule($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeEvent(Event $event): self
  68.     {
  69.         if ($this->events->removeElement($event)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($event->getSessionBlocModule() === $this) {
  72.                 $event->setSessionBlocModule(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     public function getDuree(): int
  78.     {
  79.         return $this->duree;
  80.     }
  81.     public function setDuree(int $duree): self
  82.     {
  83.         $this->duree $duree;
  84.         return $this;
  85.     }
  86. }