suivi/src/Entity/Intervention.php
2022-12-19 18:35:10 +01:00

312 lines
6.7 KiB
PHP

<?php
namespace App\Entity;
use App\Core\Entity\EntityInterface;
use App\Repository\InterventionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InterventionRepository::class)]
class Intervention implements EntityInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
protected $id;
#[ORM\ManyToMany(targetEntity: Speaker::class, inversedBy: 'interventions')]
protected $speakers;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
protected $activityReference;
#[ORM\Column(type: 'date', nullable: true)]
protected $date;
#[ORM\Column(type: 'integer', nullable: true)]
protected $groups;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
protected $levels;
#[ORM\Column(type: 'text', nullable: true)]
protected $themes;
#[ORM\Column(type: 'text', nullable: true)]
protected $content;
#[ORM\ManyToMany(targetEntity: Tool::class, inversedBy: 'interventions')]
protected $tools;
#[ORM\Column(type: 'text', nullable: true)]
protected $toolsDetails;
#[ORM\Column(type: 'text', nullable: true)]
protected $feedback;
#[ORM\Column(type: 'text', nullable: true)]
protected $vigilantPoints;
#[ORM\ManyToOne(targetEntity: ThemeType::class, inversedBy: 'interventions')]
#[ORM\JoinColumn(nullable: false)]
protected $themeType;
#[ORM\Column(type: 'text', nullable: true)]
protected $comment;
#[ORM\ManyToMany(targetEntity: EstablishmentGroup::class, inversedBy: 'interventions')]
protected $establishmentGroups;
#[ORM\Column(type: 'float', nullable: true)]
protected $price;
public function __construct()
{
$this->speakers = new ArrayCollection();
$this->tools = new ArrayCollection();
$this->establishmentGroups = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Speaker>
*/
public function getSpeakers(): Collection
{
return $this->speakers;
}
public function addSpeaker(Speaker $speaker): self
{
if (!$this->speakers->contains($speaker)) {
$this->speakers[] = $speaker;
}
return $this;
}
public function removeSpeaker(Speaker $speaker): self
{
$this->speaker->removeElement($speaker);
return $this;
}
public function getActivityReference(): ?string
{
return $this->activityReference;
}
public function setActivityReference(?string $activityReference): self
{
$this->activityReference = $activityReference;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getGroups(): ?int
{
return $this->groups;
}
public function setGroups(?int $groups): self
{
$this->groups = abs($groups);
return $this;
}
public function getLevels(): ?string
{
return $this->levels;
}
public function setLevels(?string $levels): self
{
$this->levels = $levels;
return $this;
}
public function getThemes(): ?string
{
return $this->themes;
}
public function setThemes(?string $themes): self
{
$this->themes = $themes;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
/**
* @return Collection<int, Tool>
*/
public function getTools(): Collection
{
return $this->tools;
}
public function addTool(Tool $tool): self
{
if (!$this->tools->contains($tool)) {
$this->tools[] = $tool;
}
return $this;
}
public function removeTool(Tool $tool): self
{
$this->tools->removeElement($tool);
return $this;
}
public function getToolsDetails(): ?string
{
return $this->toolsDetails;
}
public function setToolsDetails(?string $toolsDetails): self
{
$this->toolsDetails = $toolsDetails;
return $this;
}
public function getFeedback(): ?string
{
return $this->feedback;
}
public function setFeedback(?string $feedback): self
{
$this->feedback = $feedback;
return $this;
}
public function getVigilantPoints(): ?string
{
return $this->vigilantPoints;
}
public function setVigilantPoints(?string $vigilantPoints): self
{
$this->vigilantPoints = $vigilantPoints;
return $this;
}
public function getThemeType(): ?ThemeType
{
return $this->themeType;
}
public function setThemeType(?ThemeType $themeType): self
{
$this->themeType = $themeType;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getEstablishments(): ArrayCollection
{
$data = new ArrayCollection();
foreach ($this->getEstablishmentGroups() as $group) {
if (!$data->contains($group->getEstablishment())) {
$data->add($group->getEstablishment());
}
}
$establishments = $data->toArray();
usort($establishments, function($a, $b) {
return $a->getName() <=> $b->getName();
});
return new ArrayCollection($establishments);
}
/**
* @return Collection<int, EstablishmentGroup>
*/
public function getEstablishmentGroups(): Collection
{
return $this->establishmentGroups;
}
public function addEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
{
if (!$this->establishmentGroups->contains($establishmentGroup)) {
$this->establishmentGroups[] = $establishmentGroup;
}
return $this;
}
public function removeEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
{
$this->establishmentGroups->removeElement($establishmentGroup);
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
}