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

  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. #[ORM\Entity(repositoryClassSessionBlocModuleRepository::class)]
  11. class SessionBlocModule extends AbstractEntity
  12. {
  13.     #[ORM\Column(type'integer'nullabletrue)]
  14.     private ?int $duree null;
  15.     #[ORM\ManyToOne(targetEntitySession::class, inversedBy'sessionBlocModules')]
  16.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  17.     private ?Session $session=null;
  18.     #[ORM\ManyToOne(targetEntityBlocModule::class, inversedBy'sessionBlocModules')]
  19.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  20.     private ?BlocModule $blocModule=null;
  21.     #[ORM\OneToMany(targetEntityEvent::class, mappedBy'sessionBlocModule')]
  22.     private Collection $events;
  23.     public function __construct()
  24.     {
  25.         $this->events = new ArrayCollection();
  26.     }
  27.     public function getSession(): Session
  28.     {
  29.         return $this->session;
  30.     }
  31.     public function setSession(Session $session): self
  32.     {
  33.         $this->session $session;
  34.         return $this;
  35.     }
  36.     public function getBlocModule(): BlocModule
  37.     {
  38.         return $this->blocModule;
  39.     }
  40.     public function setBlocModule(BlocModule $blocModule): self
  41.     {
  42.         $this->blocModule $blocModule;
  43.         $this->setDuree($this->blocModule->getModule()->getDuree());
  44.         return $this;
  45.     }
  46.     public function getEvents(): Collection
  47.     {
  48.         return $this->events;
  49.     }
  50.     public function addEvent(Event $event): self
  51.     {
  52.         if (!$this->events->contains($event)) {
  53.             $this->events->add($event);
  54.             $event->setSessionBlocModule($this);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeEvent(Event $event): self
  59.     {
  60.         // set the owning side to null (unless already changed)
  61.         if ($this->events->removeElement($event) && $event->getSessionBlocModule() === $this) {
  62.             $event->setSessionBlocModule(null);
  63.         }
  64.         return $this;
  65.     }
  66.     public function getDuree(): int
  67.     {
  68.         return $this->duree;
  69.     }
  70.     public function setDuree(int $duree): self
  71.     {
  72.         $this->duree $duree;
  73.         return $this;
  74.     }
  75. }