<?php
namespace App\Entity\Gestiform\Formations\Session;
use App\Entity\AbstractEntity;
use App\Entity\Common\Upload;
use App\Entity\Gestiform\Formations\Session\Planning\Event;
use App\Entity\Gestiform\Users\Formateur;
use App\Repository\Gestiform\Formations\Session\FormateurEventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FormateurEventRepository::class)
*/
class FormateurEvent extends AbstractEntity
{
/**
* @ORM\Column(type="decimal", precision=10, nullable=true)
*/
private ?int $nbjoursPrevus = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $consigne = null;
/**
* @ORM\ManyToOne(targetEntity=Formateur::class, inversedBy="formateurEvents")
*/
private ?Formateur $formateur = null;
/**
* @ORM\ManyToOne(targetEntity=Event::class, inversedBy="formateurEvents")
*/
private ?Event $evenement = null;
/**
* @ORM\ManyToMany(targetEntity=Upload::class,cascade={"all"})
*/
private Collection $files;
/**
* @ORM\Column(type="json", nullable=true)
*/
private ?array $eventChilds = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $sendconvocation = null;
public function __construct()
{
$this->files = new ArrayCollection();
}
public function getEventChilds(): array
{
return $this->eventChilds ?? [];
}
public function addEventChild(string $idEvent, string $intitule): self
{
$data = $this->getEventChilds();
$exist = false;
foreach ($data as &$item) {
if ($item['idEvent'] === $idEvent) {
$item['intitule'] = $intitule;
$exist = true;
break;
}
}
if (!$exist) {
$data[] = [
'idEvent' => $idEvent,
'intitule' => $intitule,
];
}
$this->eventChilds = $data;
return $this;
}
public function removeEventChild(string $idEvent): self
{
$data = $this->getEventChilds();
foreach ($data as $key => $item) {
if ($item['idEvent'] === $idEvent) {
unset($data[$key]);
}
}
$this->eventChilds = array_values($data);
return $this;
}
public function clearEventChilds(): self
{
$this->eventChilds = [];
return $this;
}
public function getNbjoursPrevus(): ?string
{
return $this->nbjoursPrevus;
}
public function setNbjoursPrevus(?string $nbjoursPrevus): self
{
$this->nbjoursPrevus = $nbjoursPrevus;
return $this;
}
public function getFormateur(): ?Formateur
{
return $this->formateur;
}
public function setFormateur(?Formateur $formateur): self
{
$this->formateur = $formateur;
return $this;
}
public function getEvenement(): ?Event
{
return $this->evenement;
}
public function setEvenement(?Event $evenement): self
{
$this->evenement = $evenement;
return $this;
}
public function getConsigne(): ?string
{
return $this->consigne;
}
public function setConsigne(?string $consigne): self
{
$this->consigne = $consigne;
return $this;
}
public function setEventChilds(?array $eventChilds): self
{
$this->eventChilds = $eventChilds;
return $this;
}
/**
* @return Collection<int, Upload>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(Upload $file): self
{
if (!$this->files->contains($file)) {
$this->files->add($file);
}
return $this;
}
public function removeFile(Upload $file): self
{
$this->files->removeElement($file);
return $this;
}
public function getSendconvocation(): ?bool
{
return $this->sendconvocation;
}
public function setSendconvocation(?bool $sendconvocation): self
{
$this->sendconvocation = $sendconvocation;
return $this;
}
}