192 lines
3.4 KiB
PHP
192 lines
3.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
|
||
|
|
namespace App\Entity;
|
||
|
|
|
||
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
||
|
|
use Doctrine\Common\Collections\Collection;
|
||
|
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
||
|
|
use JsonSerializable;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ORM\Entity
|
||
|
|
* @ORM\Table(
|
||
|
|
* name="judges",
|
||
|
|
* indexes={
|
||
|
|
* @ORM\Index(name="j_name_idx", columns={"name"})
|
||
|
|
* }
|
||
|
|
* )
|
||
|
|
*/
|
||
|
|
class Judge implements JsonSerializable
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @ORM\Id
|
||
|
|
* @ORM\GeneratedValue
|
||
|
|
* @ORM\Column(type="integer")
|
||
|
|
* @var int
|
||
|
|
*/
|
||
|
|
private $id;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ORM\Column(name="name", type="string", length=250)
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
private $name;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ORM\Column(name="title", type="text", length=1500)
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
private $title;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ORM\Column(name="slug", type="string", length=250)
|
||
|
|
* @Gedmo\Slug(fields={"name"})
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
private $slug;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ORM\ManyToMany(targetEntity="Year", mappedBy="judges")
|
||
|
|
* @var Collection|Year[]
|
||
|
|
*/
|
||
|
|
private $years;
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$this->years = new ArrayCollection();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return int
|
||
|
|
*/
|
||
|
|
public function getId(): int
|
||
|
|
{
|
||
|
|
return $this->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param int $id
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function setId(int $id): Judge
|
||
|
|
{
|
||
|
|
$this->id = $id;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getName(): string
|
||
|
|
{
|
||
|
|
return $this->name;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param string $name
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function setName(string $name): Judge
|
||
|
|
{
|
||
|
|
$this->name = $name;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getTitle(): string
|
||
|
|
{
|
||
|
|
return $this->title;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param string $title
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function setTitle(string $title): Judge
|
||
|
|
{
|
||
|
|
$this->title = $title;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getSlug(): string
|
||
|
|
{
|
||
|
|
return $this->slug;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param string $slug
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function setSlug(string $slug): Judge
|
||
|
|
{
|
||
|
|
$this->slug = $slug;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return Year[]|Collection
|
||
|
|
*/
|
||
|
|
public function getYears(): ?Collection
|
||
|
|
{
|
||
|
|
return $this->years;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param Year $year
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function addYear(Year $year): Judge
|
||
|
|
{
|
||
|
|
if ($this->years->contains($year)) {
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
$this->years->add($year);
|
||
|
|
$year->addJudge($this);
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param Year $year
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function removeYear(Year $year): Judge
|
||
|
|
{
|
||
|
|
if (!$this->years->contains($year)) {
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
$this->years->removeElement($year);
|
||
|
|
$year->removeJudge($this);
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param Year[]|Collection $years
|
||
|
|
* @return Judge
|
||
|
|
*/
|
||
|
|
public function setYears(?Collection $years)
|
||
|
|
{
|
||
|
|
$this->years = $years;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function jsonSerialize()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'id' => $this->getId(),
|
||
|
|
'name' => $this->getName(),
|
||
|
|
'title' => $this->getTitle(),
|
||
|
|
'slug' => $this->getSlug(),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|