87 lines
1.8 KiB
PHP
87 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Core\Entity\EntityInterface;
|
|
use App\Repository\SpeakerRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass=SpeakerRepository::class)
|
|
*/
|
|
class Speaker implements EntityInterface
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
protected $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
protected $name;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=Intervention::class, mappedBy="speakers", cascade={"persist"})
|
|
*/
|
|
protected $interventions;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->interventions = new ArrayCollection();
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->getName();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): self
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Intervention>
|
|
*/
|
|
public function getInterventions(): Collection
|
|
{
|
|
return $this->interventions;
|
|
}
|
|
|
|
public function addIntervention(Intervention $intervention): self
|
|
{
|
|
if (!$this->interventions->contains($intervention)) {
|
|
$this->interventions[] = $intervention;
|
|
$intervention->addSpeaker($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeIntervention(Intervention $intervention): self
|
|
{
|
|
if ($this->interventions->removeElement($intervention)) {
|
|
$intervention->removeSpeaker($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|