* api implementation

* no auth yet
* images renamed to reflect name-prefix changes
* yearservice now gets years from judge data
This commit is contained in:
Dávid Danyi
2018-05-11 18:21:48 +02:00
parent be7bc7279d
commit 064b614ba8
23 changed files with 227 additions and 57 deletions

View File

@@ -69,7 +69,7 @@ class Awardee implements JsonSerializable
* @param int $id
* @return Awardee
*/
public function setId(int $id): Awardee
public function setId(?int $id): Awardee
{
$this->id = $id;
return $this;
@@ -78,7 +78,7 @@ class Awardee implements JsonSerializable
/**
* @return int
*/
public function getYear(): int
public function getYear(): ?int
{
return $this->year;
}
@@ -96,7 +96,7 @@ class Awardee implements JsonSerializable
/**
* @return string
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@@ -114,7 +114,7 @@ class Awardee implements JsonSerializable
/**
* @return string
*/
public function getText(): string
public function getText(): ?string
{
return $this->text;
}
@@ -132,7 +132,7 @@ class Awardee implements JsonSerializable
/**
* @return string
*/
public function getImageLabel(): string
public function getImageLabel(): ?string
{
return $this->imageLabel;
}
@@ -141,7 +141,7 @@ class Awardee implements JsonSerializable
* @param string $imageLabel
* @return Awardee
*/
public function setImageLabel(string $imageLabel): Awardee
public function setImageLabel(?string $imageLabel): Awardee
{
$this->imageLabel = $imageLabel;
return $this;
@@ -150,7 +150,7 @@ class Awardee implements JsonSerializable
/**
* @return string
*/
public function getSlug(): string
public function getSlug(): ?string
{
return $this->slug;
}

View File

@@ -34,6 +34,12 @@ class Judge implements JsonSerializable
*/
private $name;
/**
* @ORM\Column(name="prefix", type="string", length=14, nullable=true)
* @var string
*/
private $prefix;
/**
* @ORM\Column(name="slug", type="string", length=250)
* @Gedmo\Slug(fields={"name"})
@@ -42,12 +48,11 @@ class Judge implements JsonSerializable
private $slug;
/**
* @ORM\OneToMany(targetEntity="JudgeTitle", mappedBy="judge")
* @ORM\OneToMany(targetEntity="JudgeTitle", mappedBy="judge", cascade={"persist", "remove"}, orphanRemoval=true)
* @var Collection|JudgeTitle[]
*/
private $titles;
public function __construct()
{
$this->titles = new ArrayCollection();
@@ -56,7 +61,7 @@ class Judge implements JsonSerializable
/**
* @return int
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
@@ -65,7 +70,7 @@ class Judge implements JsonSerializable
* @param int $id
* @return Judge
*/
public function setId(int $id): Judge
public function setId(?int $id): Judge
{
$this->id = $id;
return $this;
@@ -74,7 +79,7 @@ class Judge implements JsonSerializable
/**
* @return string
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@@ -92,7 +97,25 @@ class Judge implements JsonSerializable
/**
* @return string
*/
public function getSlug(): string
public function getPrefix(): ?string
{
return $this->prefix;
}
/**
* @param string $prefix
* @return Judge
*/
public function setPrefix(?string $prefix): Judge
{
$this->prefix = $prefix;
return $this;
}
/**
* @return string
*/
public function getSlug(): ?string
{
return $this->slug;
}
@@ -110,11 +133,23 @@ class Judge implements JsonSerializable
/**
* @return JudgeTitle[]|Collection
*/
public function getTitles()
public function getTitles(): ?Collection
{
return $this->titles;
}
/**
* @param \Traversable $titles
* @return Judge
*/
public function addTitles(\Traversable $titles): Judge
{
foreach ($titles as $title) {
$this->addTitle($title);
}
return $this;
}
/**
* @param JudgeTitle $title
* @return Judge
@@ -123,6 +158,7 @@ class Judge implements JsonSerializable
{
if(!$this->titles->contains($title)) {
$this->titles->add($title);
$title->setJudge($this);
}
return $this;
}
@@ -135,6 +171,19 @@ class Judge implements JsonSerializable
{
if($this->titles->contains($title)) {
$this->titles->removeElement($title);
$title->setJudge(null);
}
return $this;
}
/**
* @param \Traversable $titles
* @return Judge
*/
public function removeTitles(\Traversable $titles): Judge
{
foreach ($titles as $title) {
$this->removeTitle($title);
}
return $this;
}
@@ -143,7 +192,7 @@ class Judge implements JsonSerializable
* @param JudgeTitle[]|Collection $titles
* @return Judge
*/
public function setTitles($titles)
public function setTitles($titles): Judge
{
$this->titles = $titles;
return $this;
@@ -157,6 +206,7 @@ class Judge implements JsonSerializable
return [
'id' => $this->getId(),
'name' => $this->getName(),
'prefix' => $this->getPrefix(),
'titles' => $this->getTitles()->getValues(),
'slug' => $this->getSlug(),
];

View File

@@ -39,7 +39,7 @@ class JudgeTitle implements JsonSerializable
/**
* @ORM\ManyToOne(targetEntity="Judge", inversedBy="titles")
* @ORM\JoinColumn(name="title_id", referencedColumnName="id")
* @ORM\JoinColumn(name="judge_id", referencedColumnName="id")
* @var Judge
*/
private $judge;
@@ -47,7 +47,7 @@ class JudgeTitle implements JsonSerializable
/**
* @return int
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
@@ -56,7 +56,7 @@ class JudgeTitle implements JsonSerializable
* @param int $id
* @return JudgeTitle
*/
public function setId(int $id): JudgeTitle
public function setId(?int $id): JudgeTitle
{
$this->id = $id;
return $this;
@@ -65,7 +65,7 @@ class JudgeTitle implements JsonSerializable
/**
* @return int
*/
public function getYear(): int
public function getYear(): ?int
{
return $this->year;
}
@@ -83,7 +83,7 @@ class JudgeTitle implements JsonSerializable
/**
* @return string
*/
public function getTitle(): string
public function getTitle(): ?string
{
return $this->title;
}
@@ -101,7 +101,7 @@ class JudgeTitle implements JsonSerializable
/**
* @return Judge
*/
public function getJudge(): Judge
public function getJudge(): ?Judge
{
return $this->judge;
}
@@ -110,7 +110,7 @@ class JudgeTitle implements JsonSerializable
* @param Judge $judge
* @return JudgeTitle
*/
public function setJudge(Judge $judge): JudgeTitle
public function setJudge(?Judge $judge): JudgeTitle
{
$this->judge = $judge;
return $this;