113 lines
2.3 KiB
PHP
113 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\ConferenceRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: ConferenceRepository::class)]
|
|
class Conference
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $city = null;
|
|
|
|
#[ORM\Column(length: 4)]
|
|
private ?string $year = null;
|
|
|
|
#[ORM\Column]
|
|
private ?bool $isInternational = null;
|
|
|
|
/**
|
|
* @var Collection<int, Comment>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'conference', orphanRemoval: true)]
|
|
private Collection $comments;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->comments = new ArrayCollection();
|
|
}
|
|
|
|
public function __toString(): string {
|
|
return $this->city . ' ' . $this->year;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getCity(): ?string
|
|
{
|
|
return $this->city;
|
|
}
|
|
|
|
public function setCity(string $city): static
|
|
{
|
|
$this->city = $city;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getYear(): ?string
|
|
{
|
|
return $this->year;
|
|
}
|
|
|
|
public function setYear(string $year): static
|
|
{
|
|
$this->year = $year;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isInternational(): ?bool
|
|
{
|
|
return $this->isInternational;
|
|
}
|
|
|
|
public function setInternational(bool $isInternational): static
|
|
{
|
|
$this->isInternational = $isInternational;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Comment>
|
|
*/
|
|
public function getComments(): Collection
|
|
{
|
|
return $this->comments;
|
|
}
|
|
|
|
public function addComment(Comment $comment): static
|
|
{
|
|
if (!$this->comments->contains($comment)) {
|
|
$this->comments->add($comment);
|
|
$comment->setConference($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeComment(Comment $comment): static
|
|
{
|
|
if ($this->comments->removeElement($comment)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($comment->getConference() === $this) {
|
|
$comment->setConference(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|