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