* initial api stuff

This commit is contained in:
Danyi Dávid
2018-05-11 10:46:00 +02:00
parent 77325b8e94
commit be7bc7279d
48 changed files with 3793 additions and 325 deletions

View File

@@ -34,12 +34,6 @@ class Judge implements JsonSerializable
*/
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"})
@@ -48,14 +42,15 @@ class Judge implements JsonSerializable
private $slug;
/**
* @ORM\ManyToMany(targetEntity="Year", mappedBy="judges")
* @var Collection|Year[]
* @ORM\OneToMany(targetEntity="JudgeTitle", mappedBy="judge")
* @var Collection|JudgeTitle[]
*/
private $years;
private $titles;
public function __construct()
{
$this->years = new ArrayCollection();
$this->titles = new ArrayCollection();
}
/**
@@ -94,24 +89,6 @@ class Judge implements JsonSerializable
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
*/
@@ -131,48 +108,44 @@ class Judge implements JsonSerializable
}
/**
* @return Year[]|Collection
* @return JudgeTitle[]|Collection
*/
public function getYears(): ?Collection
public function getTitles()
{
return $this->years;
return $this->titles;
}
/**
* @param Year $year
* @param JudgeTitle $title
* @return Judge
*/
public function addYear(Year $year): Judge
public function addTitle(JudgeTitle $title): Judge
{
if ($this->years->contains($year)) {
return $this;
if(!$this->titles->contains($title)) {
$this->titles->add($title);
}
$this->years->add($year);
$year->addJudge($this);
return $this;
}
/**
* @param Year $year
* @param JudgeTitle $title
* @return Judge
*/
public function removeYear(Year $year): Judge
public function removeTitle(JudgeTitle $title): Judge
{
if (!$this->years->contains($year)) {
return $this;
if($this->titles->contains($title)) {
$this->titles->removeElement($title);
}
$this->years->removeElement($year);
$year->removeJudge($this);
return $this;
}
/**
* @param Year[]|Collection $years
* @param JudgeTitle[]|Collection $titles
* @return Judge
*/
public function setYears(?Collection $years)
public function setTitles($titles)
{
$this->years = $years;
$this->titles = $titles;
return $this;
}
@@ -184,7 +157,7 @@ class Judge implements JsonSerializable
return [
'id' => $this->getId(),
'name' => $this->getName(),
'title' => $this->getTitle(),
'titles' => $this->getTitles()->getValues(),
'slug' => $this->getSlug(),
];
}