* judge-year many to many implemented, no admin yet

* judge images renamed to use generated slug, may change in the future...
This commit is contained in:
Dávid Danyi 2018-05-09 15:16:00 +02:00
parent ace6241be6
commit 77325b8e94
35 changed files with 498 additions and 118 deletions

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -34,8 +34,6 @@ class ConfigProvider
return [
'invokables' => [
Handler\PingHandler::class => Handler\PingHandler::class,
Service\JudgeManager::class => Service\JudgeManager::class,
],
'factories' => [
Handler\HomePageHandler::class => Handler\HomePageHandlerFactory::class,
@ -49,7 +47,9 @@ class ConfigProvider
Plates\StringExtension::class => Plates\StringExtensionFactory::class,
Plates\NavigationExtension::class => Plates\NavigationExtensionFactory::class,
Service\AwardeeManager::class => Service\AwardeeManagerFactory::class,
Service\JudgeManager::class => Service\JudgeManagerFactory::class,
],
];
}

View File

@ -8,10 +8,15 @@ use Gedmo\Mapping\Annotation as Gedmo;
use JsonSerializable;
/**
* @ORM\Table(name="awardees")
* @ORM\Entity
* @ORM\Table(
* name="awardees",
* indexes={
* @ORM\Index(name="a_name_idx", columns={"name"})
* }
* )
*/
class Awardee
class Awardee implements JsonSerializable
{
/**
* @ORM\Id

191
src/App/Entity/Judge.php Normal file
View File

@ -0,0 +1,191 @@
<?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(),
];
}
}

149
src/App/Entity/Year.php Normal file
View File

@ -0,0 +1,149 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
/**
* @ORM\Entity
* @ORM\Table(
* name="years",
* indexes={
* @ORM\Index(name="y_year_idx", columns={"year"})
* }
* )
*/
class Year implements JsonSerializable
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @var int
*/
private $id;
/**
* @ORM\Column(name="year", type="integer", nullable=false)
* @var int
*/
private $year;
/**
* @ORM\ManyToMany(targetEntity="Judge", inversedBy="years")
* @ORM\JoinTable(
* name="years_judges",
* joinColumns={
* @ORM\JoinColumn(name="year_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="judge_id", referencedColumnName="id")
* }
* )
* @var \Doctrine\Common\Collections\Collection|Judge[]
*/
private $judges;
public function __construct()
{
$this->judges = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Year
*/
public function setId(int $id): Year
{
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getYear(): int
{
return $this->year;
}
/**
* @param int $year
* @return Year
*/
public function setYear(int $year): Year
{
$this->year = $year;
return $this;
}
/**
* @return Judge[]|Collection
*/
public function getJudges(): ?Collection
{
return $this->judges;
}
/**
* @param Judge $judge
* @return Year
*/
public function addJudge(Judge $judge): Year
{
if ($this->judges->contains($judge)) {
return $this;
}
$this->judges->add($judge);
$judge->addYear($this);
return $this;
}
/**
* @param Judge $judge
* @return Year
*/
public function removeJudge(Judge $judge): Year
{
if (!$this->judges->contains($judge)) {
return $this;
}
$this->judges->removeElement($judge);
$judge->removeYear($this);
return $this;
}
/**
* @param Judge[]|Collection $judges
* @return Year
*/
public function setJudges(?Collection $judges): Year
{
$this->judges = $judges;
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'year' => $this->getYear(),
'judges' => $this->getJudges()->getValues(),
];
}
}

View File

@ -2,121 +2,132 @@
namespace App\Service;
use App\Entity\Judge;
use Doctrine\ORM\EntityManager;
class JudgeManager
{
/** @var EntityManager */
private $entityManager;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function getJudges()
{
return [
[
'image' => 'agnes_soos',
'name' => 'Dr Ágnes Soós',
'desc' => 'National Institute for Sports Medicine, Director General',
], [
'image' => 'balazs_nagy_lantos',
'name' => 'Balázs Nagy Lantos',
'desc' => 'Mensa HungarIQa, Former President',
], [
'image' => 'bertalan_mesko',
'name' => 'Dr Bertalan Meskó',
'desc' => 'Winner of GRAN PRIZE 2013, medical futurist, founder of Webicina',
], [
'image' => 'edit_nemeth',
'name' => 'Dr Edit Németh',
'desc' => 'ELTE Institute of Business Economics, Management and Business Law Faculty',
], [
'image' => 'erno_keszei',
'name' => 'Prof. Ernő Keszei',
'desc' => 'Eötvös Loránd University, Former Vice-Rector for Science, Research, and Innovation',
], [
'image' => 'gabor_kopek',
'name' => 'Gábor Kopek',
'desc' => 'Moholy-Nagy University of Art and Design Budapest, Former Rector',
], [
'image' => 'gabor_nemeth',
'name' => 'Dr Gábor Németh',
'desc' => 'Hungarian Intellectual Property Office, Director',
], [
'image' => 'gabor_szabo',
'name' => 'Dr Gábor Szabó',
'desc' => 'University of Szeged, Rector; Hungarian Association for Innovation, President',
], [
'image' => 'gyorgy_nagy',
'name' => 'György Nagy',
'desc' => 'Sigma Technology, Managing Director; Swedish Chamber of Commerce in Hungary, Vice-President',
], [
'image' => 'gyula_patko',
'name' => 'Dr Gyula Patkó',
'desc' => 'University of Miskolc, Former Rector',
], [
'image' => 'ildiko_csejtei',
'name' => 'Ildikó B. Csejtei',
'desc' => 'Independent Media Group, Owner, Director',
], [
'image' => 'istvan_salgo',
'name' => 'István Salgó',
'desc' => 'Business Council for Sustainable Development in Hungary, Honorary President',
], [
'image' => 'janos_durr',
'name' => 'János Dürr',
'desc' => 'Club of Hungarian Science Journalists, President',
], [
'image' => 'janos_takacs',
'name' => 'János Takács',
'desc' => 'Swedish Chamber of Commerce, President',
], [
'image' => 'jozsef_fulop',
'name' => 'József Fülöp',
'desc' => 'Moholy-Nagy University of Art and Design Budapest, Rector',
], [
'image' => 'jozsef_peter_martin',
'name' => 'Dr József Péter Martin',
'desc' => 'Transparency International Hungary, Managing Director',
], [
'image' => 'maria_judit_molnar',
'name' => 'Dr Mária Judit Molnár',
'desc' => 'SOTE Institute of Genomic Medicine and Rare Disorders, Head of the Institute',
], [
'image' => 'melinda_kamasz',
'name' => 'Melinda Kamasz',
'desc' => 'Figyelő, Deputy Editor in Chief, Figyelő Trend, Editor in Chief',
], [
'image' => 'miklos_antalovits',
'name' => 'Dr Miklós Antalovits',
'desc' => 'Budapest University of Technology and Economics, Professor Emeritus',
], [
'image' => 'miklos_bendzsel',
'name' => 'Dr Miklós Bendzsel',
'desc' => 'Hungarian Academy of Engineers, Vice-President; Hungarian Intellectual Property Office, Former President',
], [
'image' => 'peter_szauer',
'name' => 'Péter Szauer',
'desc' => 'HVG, President and Chief Executive Officer',
], [
'image' => 'richard_bogdan',
'name' => 'Richárd Bogdán',
'desc' => 'Mensa HungarIQa, President',
], [
'image' => 'rita_istivan',
'name' => 'Rita Istiván',
'desc' => 'BME, Honorary Associate Professor; Swedish Chamber of Commerce, Secretary General',
], [
'image' => 'roland_jakab',
'name' => 'Roland Jakab',
'desc' => 'Ericsson Hungary, Managing Director; Swedish Chamber of Commerce, Member of the Board',
], [
'image' => 'szabolcs_farkas',
'name' => 'Dr Szabolcs Farkas',
'desc' => 'Hungarian Intellectual Property Office, Vice-President',
], [
'image' => 'zoltan_bruckner',
'name' => 'Zoltán Bruckner',
'desc' => 'Primus Capital Management, Investment Director, Managing Partner',
], [
'image' => 'viktor_luszcz',
'name' => 'Dr Viktor Łuszcz',
'desc' => 'Hungarian Intellectual Property Office, President',
]
];
// return [
// [
// 'image' => 'agnes_soos',
// 'name' => 'Dr Ágnes Soós',
// 'desc' => 'National Institute for Sports Medicine, Director General',
// ], [
// 'image' => 'balazs_nagy_lantos',
// 'name' => 'Balázs Nagy Lantos',
// 'desc' => 'Mensa HungarIQa, Former President',
// ], [
// 'image' => 'bertalan_mesko',
// 'name' => 'Dr Bertalan Meskó',
// 'desc' => 'Winner of GRAN PRIZE 2013, medical futurist, founder of Webicina',
// ], [
// 'image' => 'edit_nemeth',
// 'name' => 'Dr Edit Németh',
// 'desc' => 'ELTE Institute of Business Economics, Management and Business Law Faculty',
// ], [
// 'image' => 'erno_keszei',
// 'name' => 'Prof. Ernő Keszei',
// 'desc' => 'Eötvös Loránd University, Former Vice-Rector for Science, Research, and Innovation',
// ], [
// 'image' => 'gabor_kopek',
// 'name' => 'Gábor Kopek',
// 'desc' => 'Moholy-Nagy University of Art and Design Budapest, Former Rector',
// ], [
// 'image' => 'gabor_nemeth',
// 'name' => 'Dr Gábor Németh',
// 'desc' => 'Hungarian Intellectual Property Office, Director',
// ], [
// 'image' => 'gabor_szabo',
// 'name' => 'Dr Gábor Szabó',
// 'desc' => 'University of Szeged, Rector; Hungarian Association for Innovation, President',
// ], [
// 'image' => 'gyorgy_nagy',
// 'name' => 'György Nagy',
// 'desc' => 'Sigma Technology, Managing Director; Swedish Chamber of Commerce in Hungary, Vice-President',
// ], [
// 'image' => 'gyula_patko',
// 'name' => 'Dr Gyula Patkó',
// 'desc' => 'University of Miskolc, Former Rector',
// ], [
// 'image' => 'ildiko_csejtei',
// 'name' => 'Ildikó B. Csejtei',
// 'desc' => 'Independent Media Group, Owner, Director',
// ], [
// 'image' => 'istvan_salgo',
// 'name' => 'István Salgó',
// 'desc' => 'Business Council for Sustainable Development in Hungary, Honorary President',
// ], [
// 'image' => 'janos_durr',
// 'name' => 'János Dürr',
// 'desc' => 'Club of Hungarian Science Journalists, President',
// ], [
// 'image' => 'janos_takacs',
// 'name' => 'János Takács',
// 'desc' => 'Swedish Chamber of Commerce, President',
// ], [
// 'image' => 'jozsef_fulop',
// 'name' => 'József Fülöp',
// 'desc' => 'Moholy-Nagy University of Art and Design Budapest, Rector',
// ], [
// 'image' => 'jozsef_peter_martin',
// 'name' => 'Dr József Péter Martin',
// 'desc' => 'Transparency International Hungary, Managing Director',
// ], [
// 'image' => 'maria_judit_molnar',
// 'name' => 'Dr Mária Judit Molnár',
// 'desc' => 'SOTE Institute of Genomic Medicine and Rare Disorders, Head of the Institute',
// ], [
// 'image' => 'melinda_kamasz',
// 'name' => 'Melinda Kamasz',
// 'desc' => 'Figyelő, Deputy Editor in Chief, Figyelő Trend, Editor in Chief',
// ], [
// 'image' => 'miklos_antalovits',
// 'name' => 'Dr Miklós Antalovits',
// 'desc' => 'Budapest University of Technology and Economics, Professor Emeritus',
// ], [
// 'image' => 'miklos_bendzsel',
// 'name' => 'Dr Miklós Bendzsel',
// 'desc' => 'Hungarian Academy of Engineers, Vice-President; Hungarian Intellectual Property Office, Former President',
// ], [
// 'image' => 'peter_szauer',
// 'name' => 'Péter Szauer',
// 'desc' => 'HVG, President and Chief Executive Officer',
// ], [
// 'image' => 'richard_bogdan',
// 'name' => 'Richárd Bogdán',
// 'desc' => 'Mensa HungarIQa, President',
// ], [
// 'image' => 'rita_istivan',
// 'name' => 'Rita Istiván',
// 'desc' => 'BME, Honorary Associate Professor; Swedish Chamber of Commerce, Secretary General',
// ], [
// 'image' => 'roland_jakab',
// 'name' => 'Roland Jakab',
// 'desc' => 'Ericsson Hungary, Managing Director; Swedish Chamber of Commerce, Member of the Board',
// ], [
// 'image' => 'szabolcs_farkas',
// 'name' => 'Dr Szabolcs Farkas',
// 'desc' => 'Hungarian Intellectual Property Office, Vice-President',
// ], [
// 'image' => 'zoltan_bruckner',
// 'name' => 'Zoltán Bruckner',
// 'desc' => 'Primus Capital Management, Investment Director, Managing Partner',
// ], [
// 'image' => 'viktor_luszcz',
// 'name' => 'Dr Viktor Łuszcz',
// 'desc' => 'Hungarian Intellectual Property Office, President',
// ]
// ];
}
/**
@ -126,6 +137,13 @@ class JudgeManager
*/
public function getJudgesByYear(int $year)
{
return $this->getJudges();
$qb = $this->entityManager->createQueryBuilder();
return $qb->select('j')
->from(Judge::class, 'j')
->innerJoin('j.years', 'y')
->where('y.year = :year')
->setParameter('year', $year)
->getQuery()
->getArrayResult();
}
}

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Service;
use Doctrine\ORM\EntityManager;
use Psr\Container\ContainerInterface;
class JudgeManagerFactory
{
public function __invoke(ContainerInterface $container): JudgeManager
{
$entityManager = $container->get(EntityManager::class);
return new JudgeManager($entityManager);
}
}

View File

@ -2,9 +2,9 @@
<h1><?=$year?> judges</h1>
<?php foreach ($judges as $judge): ?>
<section class="judge">
<img class="profile" src="<?= $this->serverurl(sprintf('/img/judges/%s.jpg', $judge['image'])) ?>">
<img class="profile" src="<?= $this->serverurl(sprintf('/img/judges/%s.jpg', $judge['slug'])) ?>">
<span class="title"><?= $judge['name']?></span><br>
<span class="description"><?= $judge['desc']?></span>
<span class="description"><?= $judge['title']?></span>
</section>
<?php endforeach; ?>
</section>