diff --git a/public/img/judges/ildiko_csejtei.jpg b/public/img/judges/b-ildiko-csejtei.jpg similarity index 100% rename from public/img/judges/ildiko_csejtei.jpg rename to public/img/judges/b-ildiko-csejtei.jpg diff --git a/public/img/judges/balazs_nagy_lantos.jpg b/public/img/judges/balazs-nagy-lantos.jpg similarity index 100% rename from public/img/judges/balazs_nagy_lantos.jpg rename to public/img/judges/balazs-nagy-lantos.jpg diff --git a/public/img/judges/agnes_soos.jpg b/public/img/judges/dr-agnes-soos.jpg similarity index 100% rename from public/img/judges/agnes_soos.jpg rename to public/img/judges/dr-agnes-soos.jpg diff --git a/public/img/judges/bertalan_mesko.jpg b/public/img/judges/dr-bertalan-mesko.jpg similarity index 100% rename from public/img/judges/bertalan_mesko.jpg rename to public/img/judges/dr-bertalan-mesko.jpg diff --git a/public/img/judges/edit_nemeth.jpg b/public/img/judges/dr-edit-nemeth.jpg similarity index 100% rename from public/img/judges/edit_nemeth.jpg rename to public/img/judges/dr-edit-nemeth.jpg diff --git a/public/img/judges/gabor_szabo.jpg b/public/img/judges/dr-gabor-szabo.jpg similarity index 100% rename from public/img/judges/gabor_szabo.jpg rename to public/img/judges/dr-gabor-szabo.jpg diff --git a/public/img/judges/gyula_patko.jpg b/public/img/judges/dr-gyula-patko.jpg similarity index 100% rename from public/img/judges/gyula_patko.jpg rename to public/img/judges/dr-gyula-patko.jpg diff --git a/public/img/judges/maria_judit_molnar.jpg b/public/img/judges/dr-maria-judit-molnar.jpg similarity index 100% rename from public/img/judges/maria_judit_molnar.jpg rename to public/img/judges/dr-maria-judit-molnar.jpg diff --git a/public/img/judges/miklos_antalovits.jpg b/public/img/judges/dr-miklos-antalovits.jpg similarity index 100% rename from public/img/judges/miklos_antalovits.jpg rename to public/img/judges/dr-miklos-antalovits.jpg diff --git a/public/img/judges/miklos_bendzsel.jpg b/public/img/judges/dr-miklos-bendzsel.jpg similarity index 100% rename from public/img/judges/miklos_bendzsel.jpg rename to public/img/judges/dr-miklos-bendzsel.jpg diff --git a/public/img/judges/szabolcs_farkas.jpg b/public/img/judges/dr-szabolcs-farkas.jpg similarity index 100% rename from public/img/judges/szabolcs_farkas.jpg rename to public/img/judges/dr-szabolcs-farkas.jpg diff --git a/public/img/judges/erno_keszei.jpg b/public/img/judges/erno-keszei.jpg similarity index 100% rename from public/img/judges/erno_keszei.jpg rename to public/img/judges/erno-keszei.jpg diff --git a/public/img/judges/gabor_kopek.jpg b/public/img/judges/gabor-kopek.jpg similarity index 100% rename from public/img/judges/gabor_kopek.jpg rename to public/img/judges/gabor-kopek.jpg diff --git a/public/img/judges/gabor_nemeth.jpg b/public/img/judges/gabor-nemeth.jpg similarity index 100% rename from public/img/judges/gabor_nemeth.jpg rename to public/img/judges/gabor-nemeth.jpg diff --git a/public/img/judges/gyorgy_nagy.jpg b/public/img/judges/gyorgy-nagy.jpg similarity index 100% rename from public/img/judges/gyorgy_nagy.jpg rename to public/img/judges/gyorgy-nagy.jpg diff --git a/public/img/judges/istvan_salgo.jpg b/public/img/judges/istvan-salgo.jpg similarity index 100% rename from public/img/judges/istvan_salgo.jpg rename to public/img/judges/istvan-salgo.jpg diff --git a/public/img/judges/janos_durr.jpg b/public/img/judges/janos-durr.jpg similarity index 100% rename from public/img/judges/janos_durr.jpg rename to public/img/judges/janos-durr.jpg diff --git a/public/img/judges/janos_takacs.jpg b/public/img/judges/janos-takacs.jpg similarity index 100% rename from public/img/judges/janos_takacs.jpg rename to public/img/judges/janos-takacs.jpg diff --git a/public/img/judges/jozsef_fulop.jpg b/public/img/judges/jozsef-fulop.jpg similarity index 100% rename from public/img/judges/jozsef_fulop.jpg rename to public/img/judges/jozsef-fulop.jpg diff --git a/public/img/judges/jozsef_peter_martin.jpg b/public/img/judges/jozsef-peter-martin.jpg similarity index 100% rename from public/img/judges/jozsef_peter_martin.jpg rename to public/img/judges/jozsef-peter-martin.jpg diff --git a/public/img/judges/marton_juhasz.jpg b/public/img/judges/marton-juhasz.jpg similarity index 100% rename from public/img/judges/marton_juhasz.jpg rename to public/img/judges/marton-juhasz.jpg diff --git a/public/img/judges/melinda_kamasz.jpg b/public/img/judges/melinda-kamasz.jpg similarity index 100% rename from public/img/judges/melinda_kamasz.jpg rename to public/img/judges/melinda-kamasz.jpg diff --git a/public/img/judges/peter_szauer.jpg b/public/img/judges/peter-szauer.jpg similarity index 100% rename from public/img/judges/peter_szauer.jpg rename to public/img/judges/peter-szauer.jpg diff --git a/public/img/judges/richard_bogdan.jpg b/public/img/judges/richard-bogdan.jpg similarity index 100% rename from public/img/judges/richard_bogdan.jpg rename to public/img/judges/richard-bogdan.jpg diff --git a/public/img/judges/rita_istivan.jpg b/public/img/judges/rita-istivan.jpg similarity index 100% rename from public/img/judges/rita_istivan.jpg rename to public/img/judges/rita-istivan.jpg diff --git a/public/img/judges/roland_jakab.jpg b/public/img/judges/roland-jakab.jpg similarity index 100% rename from public/img/judges/roland_jakab.jpg rename to public/img/judges/roland-jakab.jpg diff --git a/public/img/judges/viktor_luszcz.jpg b/public/img/judges/viktor-luszcz.jpg similarity index 100% rename from public/img/judges/viktor_luszcz.jpg rename to public/img/judges/viktor-luszcz.jpg diff --git a/public/img/judges/zoltan_bruckner.jpg b/public/img/judges/zoltan-bruckner.jpg similarity index 100% rename from public/img/judges/zoltan_bruckner.jpg rename to public/img/judges/zoltan-bruckner.jpg diff --git a/src/App/ConfigProvider.php b/src/App/ConfigProvider.php index f03aa13..110e817 100644 --- a/src/App/ConfigProvider.php +++ b/src/App/ConfigProvider.php @@ -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, ], ]; } diff --git a/src/App/Entity/Awardee.php b/src/App/Entity/Awardee.php index 1b22b4f..e230b81 100644 --- a/src/App/Entity/Awardee.php +++ b/src/App/Entity/Awardee.php @@ -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 diff --git a/src/App/Entity/Judge.php b/src/App/Entity/Judge.php new file mode 100644 index 0000000..4887bd5 --- /dev/null +++ b/src/App/Entity/Judge.php @@ -0,0 +1,191 @@ +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(), + ]; + } +} diff --git a/src/App/Entity/Year.php b/src/App/Entity/Year.php new file mode 100644 index 0000000..476bc91 --- /dev/null +++ b/src/App/Entity/Year.php @@ -0,0 +1,149 @@ +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(), + ]; + } +} diff --git a/src/App/Service/JudgeManager.php b/src/App/Service/JudgeManager.php index 716f957..c579b9a 100644 --- a/src/App/Service/JudgeManager.php +++ b/src/App/Service/JudgeManager.php @@ -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(); } } diff --git a/src/App/Service/JudgeManagerFactory.php b/src/App/Service/JudgeManagerFactory.php new file mode 100644 index 0000000..940acc0 --- /dev/null +++ b/src/App/Service/JudgeManagerFactory.php @@ -0,0 +1,17 @@ +get(EntityManager::class); + return new JudgeManager($entityManager); + } +} diff --git a/templates/app/judges.inc.phtml b/templates/app/judges.inc.phtml index 0ba2c36..2fbefb5 100644 --- a/templates/app/judges.inc.phtml +++ b/templates/app/judges.inc.phtml @@ -2,9 +2,9 @@
+
= $judge['name']?>