<?php
namespace App\Entity\Gestiform\Formations\Session;
use App\Entity\AbstractEntity;
use App\Entity\Gestiform\Formations\Catalogue\Parcours\Bloc\BlocModule;
use App\Entity\Gestiform\Formations\Session\Planning\Event;
use App\Repository\Gestiform\Formations\Session\SessionBlocModuleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use function Symfony\Component\Translation\t;
/**
* @ORM\Entity(repositoryClass=SessionBlocModuleRepository::class)
*/
class SessionBlocModule extends AbstractEntity
{
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $duree = null;
/**
* @ORM\ManyToOne(targetEntity=Session::class, inversedBy="sessionBlocModules")
*/
private Session $session;
/**
* @ORM\ManyToOne(targetEntity=BlocModule::class, inversedBy="sessionBlocModules")
*/
private BlocModule $blocModule;
/**
* @ORM\OneToMany(targetEntity=Event::class, mappedBy="sessionBlocModule")
*/
private Collection $events;
public function __construct()
{
$this->events = new ArrayCollection();
}
public function getSession(): Session
{
return $this->session;
}
public function setSession(Session $session): self
{
$this->session = $session;
return $this;
}
public function getBlocModule(): BlocModule
{
return $this->blocModule;
}
public function setBlocModule(BlocModule $blocModule): self
{
$this->blocModule = $blocModule;
$this->setDuree($this->blocModule->getModule()->getDuree());
return $this;
}
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): self
{
if (!$this->events->contains($event)) {
$this->events->add($event);
$event->setSessionBlocModule($this);
}
return $this;
}
public function removeEvent(Event $event): self
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
if ($event->getSessionBlocModule() === $this) {
$event->setSessionBlocModule(null);
}
}
return $this;
}
public function getDuree(): int
{
return $this->duree;
}
public function setDuree(int $duree): self
{
$this->duree = $duree;
return $this;
}
}