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

164 lines
3.4 KiB
PHP

<?php
namespace App\Entity;
use App\Core\Entity\EntityInterface;
use App\Repository\EventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EventRepository::class)]
class Event implements EntityInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
protected $id;
#[ORM\Column(type: 'string', length: 40)]
protected $uid;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
protected $summary;
#[ORM\Column(type: 'text', nullable: true)]
protected $description;
#[ORM\Column(type: 'datetime', nullable: true)]
protected $startAt;
#[ORM\Column(type: 'datetime', nullable: true)]
protected $finishAt;
#[ORM\ManyToMany(targetEntity: Speaker::class, inversedBy: 'events')]
protected $speakers;
#[ORM\ManyToMany(targetEntity: Project::class, inversedBy: 'events')]
protected $projects;
public function __construct()
{
$this->speakers = new ArrayCollection();
$this->projects = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUid(): ?string
{
return $this->uid;
}
public function setUid(string $uid): self
{
$this->uid = $uid;
return $this;
}
public function getSummary(): ?string
{
return $this->summary;
}
public function setSummary(?string $summary): self
{
$this->summary = $summary;
return $this;
}
public function getCleanedDescription(): string
{
return trim(preg_replace('/\s*#\{project:\d+\}\s*/', "\n", $this->getDescription()));
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getStartAt(): ?\DateTimeInterface
{
return $this->startAt;
}
public function setStartAt(?\DateTimeInterface $startAt): self
{
$this->startAt = $startAt;
return $this;
}
public function getFinishAt(): ?\DateTimeInterface
{
return $this->finishAt;
}
public function setFinishAt(?\DateTimeInterface $finishAt): self
{
$this->finishAt = $finishAt;
return $this;
}
/**
* @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->speakers->removeElement($speaker);
return $this;
}
/**
* @return Collection<int, Project>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Project $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
}
return $this;
}
public function removeProject(Project $project): self
{
$this->projects->removeElement($project);
return $this;
}
}