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

  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Session;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Common\Upload;
  5. use App\Entity\Gestiform\Formations\Session\Planning\Event;
  6. use App\Entity\Gestiform\Users\Formateur;
  7. use App\Repository\Gestiform\Formations\Session\FormateurEventRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. #[ORM\Entity(repositoryClassFormateurEventRepository::class)]
  12. class FormateurEvent extends AbstractEntity
  13. {
  14.     #[ORM\Column(type'decimal'precision10nullabletrue)]
  15.     private ?int $nbjoursPrevus null;
  16.     #[ORM\Column(type'string'length255nullabletrue)]
  17.     private ?string $consigne null;
  18.     #[ORM\ManyToOne(targetEntityFormateur::class, inversedBy'formateurEvents')]
  19.     private ?Formateur $formateur null;
  20.     #[ORM\ManyToOne(targetEntityEvent::class, inversedBy'formateurEvents')]
  21.     private ?Event $evenement null;
  22.     #[ORM\ManyToMany(targetEntityUpload::class, cascade: ['all'])]
  23.     private Collection $files;
  24.     #[ORM\Column(type'json'nullabletrue)]
  25.     private ?array $eventChilds null;
  26.     #[ORM\Column(type'boolean'nullabletrue)]
  27.     private ?bool $sendconvocation null;
  28.     public function __construct()
  29.     {
  30.         $this->files = new ArrayCollection();
  31.     }
  32.     public function getEventChilds(): array
  33.     {
  34.         return $this->eventChilds ?? [];
  35.     }
  36.     public function addEventChild(string $idEventstring $intitule): self
  37.     {
  38.         $data $this->getEventChilds();
  39.         $exist false;
  40.         foreach ($data as &$item) {
  41.             if ($item['idEvent'] === $idEvent) {
  42.                 $item['intitule'] = $intitule;
  43.                 $exist true;
  44.                 break;
  45.             }
  46.         }
  47.         if (!$exist) {
  48.             $data[] = [
  49.                 'idEvent' => $idEvent,
  50.                 'intitule' => $intitule,
  51.             ];
  52.         }
  53.         $this->eventChilds $data;
  54.         return $this;
  55.     }
  56.     public function removeEventChild(string $idEvent): self
  57.     {
  58.         $data $this->getEventChilds();
  59.         foreach ($data as $key => $item) {
  60.             if ($item['idEvent'] === $idEvent) {
  61.                 unset($data[$key]);
  62.             }
  63.         }
  64.         $this->eventChilds array_values($data);
  65.         return $this;
  66.     }
  67.     public function clearEventChilds(): self
  68.     {
  69.         $this->eventChilds = [];
  70.         return $this;
  71.     }
  72.     public function getNbjoursPrevus(): ?string
  73.     {
  74.         return $this->nbjoursPrevus;
  75.     }
  76.     public function setNbjoursPrevus(?string $nbjoursPrevus): self
  77.     {
  78.         $this->nbjoursPrevus $nbjoursPrevus;
  79.         return $this;
  80.     }
  81.     public function getFormateur(): ?Formateur
  82.     {
  83.         return $this->formateur;
  84.     }
  85.     public function setFormateur(?Formateur $formateur): self
  86.     {
  87.         $this->formateur $formateur;
  88.         return $this;
  89.     }
  90.     public function getEvenement(): ?Event
  91.     {
  92.         return $this->evenement;
  93.     }
  94.     public function setEvenement(?Event $evenement): self
  95.     {
  96.         $this->evenement $evenement;
  97.         return $this;
  98.     }
  99.     public function getConsigne(): ?string
  100.     {
  101.         return $this->consigne;
  102.     }
  103.     public function setConsigne(?string $consigne): self
  104.     {
  105.         $this->consigne $consigne;
  106.         return $this;
  107.     }
  108.     public function setEventChilds(?array $eventChilds): self
  109.     {
  110.         $this->eventChilds $eventChilds;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection<int, Upload>
  115.      */
  116.     public function getFiles(): Collection
  117.     {
  118.         return $this->files;
  119.     }
  120.     public function addFile(Upload $file): self
  121.     {
  122.         if (!$this->files->contains($file)) {
  123.             $this->files->add($file);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeFile(Upload $file): self
  128.     {
  129.         $this->files->removeElement($file);
  130.         return $this;
  131.     }
  132.     
  133.     public function getSendconvocation(): ?bool
  134.     {
  135.         return $this->sendconvocation;
  136.     }
  137.     public function setSendconvocation(?bool $sendconvocation): self
  138.     {
  139.         $this->sendconvocation $sendconvocation;
  140.         return $this;
  141.     }
  142. }