* mostly complete
This commit is contained in:
@@ -34,11 +34,22 @@ class ConfigProvider
|
||||
return [
|
||||
'invokables' => [
|
||||
Handler\PingHandler::class => Handler\PingHandler::class,
|
||||
|
||||
Service\JudgeManager::class => Service\JudgeManager::class,
|
||||
],
|
||||
'factories' => [
|
||||
Handler\HomePageHandler::class => Handler\HomePageHandlerFactory::class,
|
||||
Handler\ArticleHandler::class => Handler\ArticleHandlerFactory::class,
|
||||
Handler\AwardeeHandler::class => Handler\AwardeeHandlerFactory::class,
|
||||
Handler\JudgesHandler::class => Handler\JudgesHandlerFactory::class,
|
||||
Handler\ProfileHandler::class => Handler\ProfileHandlerFactory::class,
|
||||
|
||||
Handler\AwardeeRedirectHandler::class => Handler\AwardeeRedirectHandlerFactory::class,
|
||||
Handler\PrizeRedirectHandler::class => Handler\PrizeRedirectHandlerFactory::class,
|
||||
|
||||
Plates\StringExtension::class => Plates\StringExtensionFactory::class,
|
||||
Plates\NavigationExtension::class => Plates\NavigationExtensionFactory::class,
|
||||
Service\AwardeeManager::class => Service\AwardeeManagerFactory::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
177
src/App/Entity/Awardee.php
Normal file
177
src/App/Entity/Awardee.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="awardees")
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class Awardee
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="year", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $year;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=200, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="description", type="text", nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="image_label", type="string", length=255, unique=true)
|
||||
* @var string
|
||||
*/
|
||||
private $imageLabel;
|
||||
|
||||
/**
|
||||
* @Gedmo\Slug(fields={"year", "name"})
|
||||
* @ORM\Column(length=128, unique=true)
|
||||
* @var string
|
||||
*/
|
||||
private $slug;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setId(int $id): Awardee
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setYear(int $year): Awardee
|
||||
{
|
||||
$this->year = $year;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setName(string $name): Awardee
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setText(string $text): Awardee
|
||||
{
|
||||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImageLabel(): string
|
||||
{
|
||||
return $this->imageLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $imageLabel
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setImageLabel(string $imageLabel): Awardee
|
||||
{
|
||||
$this->imageLabel = $imageLabel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug(): string
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $slug
|
||||
* @return Awardee
|
||||
*/
|
||||
public function setSlug(string $slug): Awardee
|
||||
{
|
||||
$this->slug = $slug;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'year' => $this->getYear(),
|
||||
'name' => $this->getYear(),
|
||||
'text' => $this->getText(),
|
||||
'imageLabel' => $this->getImageLabel(),
|
||||
'slug' => $this->getSlug(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
src/App/Handler/ArticleHandler.php
Normal file
27
src/App/Handler/ArticleHandler.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class ArticleHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var TemplateRendererInterface */
|
||||
private $template;
|
||||
|
||||
public function __construct(TemplateRendererInterface $template) {
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
$articleTemplate = $request->getAttribute('article');
|
||||
return new HtmlResponse($this->template->render("app::{$articleTemplate}"));
|
||||
}
|
||||
}
|
||||
19
src/App/Handler/ArticleHandlerFactory.php
Normal file
19
src/App/Handler/ArticleHandlerFactory.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class ArticleHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : RequestHandlerInterface
|
||||
{
|
||||
$template = $container->get(TemplateRendererInterface::class);
|
||||
return new ArticleHandler($template);
|
||||
}
|
||||
}
|
||||
39
src/App/Handler/AwardeeHandler.php
Normal file
39
src/App/Handler/AwardeeHandler.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Service\AwardeeManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class AwardeeHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var TemplateRendererInterface */
|
||||
private $template;
|
||||
|
||||
/** @var AwardeeManager */
|
||||
private $awardeeManager;
|
||||
|
||||
public function __construct(
|
||||
TemplateRendererInterface $template,
|
||||
AwardeeManager $awardeeManager
|
||||
) {
|
||||
$this->template = $template;
|
||||
$this->awardeeManager = $awardeeManager;
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
$year = $request->getAttribute('year');
|
||||
$awardees = $this->awardeeManager->getJudgesByYear((int)$year);
|
||||
return new HtmlResponse($this->template->render("app::awardees", [
|
||||
'year' => $year,
|
||||
'awardees' => $awardees,
|
||||
]));
|
||||
}
|
||||
}
|
||||
20
src/App/Handler/AwardeeHandlerFactory.php
Normal file
20
src/App/Handler/AwardeeHandlerFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Service\AwardeeManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class AwardeeHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container): RequestHandlerInterface
|
||||
{
|
||||
$template = $container->get(TemplateRendererInterface::class);
|
||||
$awardeeManager = $container->get(AwardeeManager::class);
|
||||
return new AwardeeHandler($template, $awardeeManager);
|
||||
}
|
||||
}
|
||||
49
src/App/Handler/AwardeeRedirectHandler.php
Normal file
49
src/App/Handler/AwardeeRedirectHandler.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Entity\Awardee;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\RedirectResponse;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class AwardeeRedirectHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var UrlHelper */
|
||||
private $urlHelper;
|
||||
|
||||
/** @var EntityManager */
|
||||
private $entityManager;
|
||||
|
||||
public function __construct(
|
||||
UrlHelper $urlHelper,
|
||||
EntityManager $entityManager
|
||||
) {
|
||||
$this->urlHelper = $urlHelper;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @return ResponseInterface
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
$maxYear = $qb->select('max(a.year)')
|
||||
->from(Awardee::class, 'a')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
||||
$url = $this->urlHelper->generate('awardees-by-year', [
|
||||
'year' => $maxYear,
|
||||
]);
|
||||
return new RedirectResponse($url);
|
||||
}
|
||||
}
|
||||
20
src/App/Handler/AwardeeRedirectHandlerFactory.php
Normal file
20
src/App/Handler/AwardeeRedirectHandlerFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class AwardeeRedirectHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : RequestHandlerInterface
|
||||
{
|
||||
$urlHelper = $container->get(UrlHelper::class);
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
return new AwardeeRedirectHandler($urlHelper, $entityManager);
|
||||
}
|
||||
}
|
||||
35
src/App/Handler/JudgesHandler.php
Normal file
35
src/App/Handler/JudgesHandler.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Service\JudgeManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class JudgesHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var TemplateRendererInterface */
|
||||
private $template;
|
||||
|
||||
/** @var JudgeManager */
|
||||
private $judgeManager;
|
||||
|
||||
public function __construct(
|
||||
TemplateRendererInterface $template,
|
||||
JudgeManager $judgeManager
|
||||
) {
|
||||
$this->template = $template;
|
||||
$this->judgeManager = $judgeManager;
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
$data['judges'] = $this->judgeManager->getJudges();
|
||||
return new HtmlResponse($this->template->render("app::judges", $data));
|
||||
}
|
||||
}
|
||||
20
src/App/Handler/JudgesHandlerFactory.php
Normal file
20
src/App/Handler/JudgesHandlerFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Service\JudgeManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class JudgesHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : RequestHandlerInterface
|
||||
{
|
||||
$template = $container->get(TemplateRendererInterface::class);
|
||||
$judgeManager = $container->get(JudgeManager::class);
|
||||
return new JudgesHandler($template, $judgeManager);
|
||||
}
|
||||
}
|
||||
30
src/App/Handler/PrizeRedirectHandler.php
Normal file
30
src/App/Handler/PrizeRedirectHandler.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\RedirectResponse;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class PrizeRedirectHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var UrlHelper */
|
||||
private $urlHelper;
|
||||
|
||||
public function __construct(UrlHelper $urlHelper)
|
||||
{
|
||||
$this->urlHelper = $urlHelper;
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
$url = $this->urlHelper->generate('the-prize.article', [
|
||||
'article' => 'background-and-purpose',
|
||||
]);
|
||||
return new RedirectResponse($url);
|
||||
}
|
||||
}
|
||||
18
src/App/Handler/PrizeRedirectHandlerFactory.php
Normal file
18
src/App/Handler/PrizeRedirectHandlerFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class PrizeRedirectHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : RequestHandlerInterface
|
||||
{
|
||||
$urlHelper = $container->get(UrlHelper::class);
|
||||
return new PrizeRedirectHandler($urlHelper);
|
||||
}
|
||||
}
|
||||
41
src/App/Handler/ProfileHandler.php
Normal file
41
src/App/Handler/ProfileHandler.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use App\Entity\Awardee;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class ProfileHandler implements RequestHandlerInterface
|
||||
{
|
||||
/** @var TemplateRendererInterface */
|
||||
private $template;
|
||||
|
||||
/** @var EntityManager */
|
||||
private $entityManager;
|
||||
|
||||
public function __construct(
|
||||
TemplateRendererInterface $template,
|
||||
EntityManager $entityManager
|
||||
) {
|
||||
$this->template = $template;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
$slug = $request->getAttribute('slug');
|
||||
$awardee = $this->entityManager->getRepository(Awardee::class)->findOneBy([
|
||||
'slug' => $slug,
|
||||
]);
|
||||
return new HtmlResponse($this->template->render("app::profile", [
|
||||
'awardee' => $awardee,
|
||||
]));
|
||||
}
|
||||
}
|
||||
20
src/App/Handler/ProfileHandlerFactory.php
Normal file
20
src/App/Handler/ProfileHandlerFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Handler;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class ProfileHandlerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : RequestHandlerInterface
|
||||
{
|
||||
$template = $container->get(TemplateRendererInterface::class);
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
return new ProfileHandler($template, $entityManager);
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Plates;
|
||||
|
||||
use App\Entity\Awardee;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Knp\Menu\Matcher\Matcher;
|
||||
use Knp\Menu\Matcher\Voter\UriVoter;
|
||||
use Knp\Menu\Matcher\Voter\VoterInterface;
|
||||
use Knp\Menu\MenuFactory;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Knp\Menu\Renderer\ListRenderer;
|
||||
@@ -20,12 +21,19 @@ class NavigationExtension implements ExtensionInterface
|
||||
/** @var RouterInterface */
|
||||
private $router;
|
||||
|
||||
/** @var EntityManager */
|
||||
private $entityManager;
|
||||
|
||||
/** @var MenuItem */
|
||||
private $menu;
|
||||
|
||||
public function __construct(RouterInterface $router)
|
||||
public function __construct(
|
||||
RouterInterface $router,
|
||||
EntityManager $entityManager
|
||||
)
|
||||
{
|
||||
$this->router = $router;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,16 +70,16 @@ class NavigationExtension implements ExtensionInterface
|
||||
'uri' => $this->getUriFromRouter('the-prize')
|
||||
]);
|
||||
$prizeMenu->addChild("Background and Purpose", [
|
||||
'uri' => $this->getUriFromRouter('the-prize.bg')
|
||||
'uri' => $this->getUriFromRouter('the-prize.article', ['article' => 'background-and-purpose'])
|
||||
]);
|
||||
$prizeMenu->addChild("Description and Values", [
|
||||
'uri' => $this->getUriFromRouter('the-prize.desc')
|
||||
'uri' => $this->getUriFromRouter('the-prize.article', ['article' => 'description-and-values'])
|
||||
]);
|
||||
$prizeMenu->addChild("Aspect for Selection", [
|
||||
'uri' => $this->getUriFromRouter('the-prize.aspect')
|
||||
'uri' => $this->getUriFromRouter('the-prize.article', ['article' => 'aspect-for-selection'])
|
||||
]);
|
||||
$prizeMenu->addChild("Gran Prize Award and Events", [
|
||||
'uri' => $this->getUriFromRouter('the-prize.events')
|
||||
'uri' => $this->getUriFromRouter('the-prize.article', ['article' => 'gran-prize-award-events'])
|
||||
]);
|
||||
|
||||
$this->menu->addChild(strtoupper("Judges"), [
|
||||
@@ -91,11 +99,20 @@ class NavigationExtension implements ExtensionInterface
|
||||
|
||||
private function populateAwardeesSubmenu(ItemInterface $awardeesMenu)
|
||||
{
|
||||
$year = (int)date("Y");
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
$result = $qb->select('a.year')
|
||||
->from(Awardee::class, 'a')
|
||||
->orderBy('a.year', 'DESC')
|
||||
->getQuery()
|
||||
->getScalarResult();
|
||||
|
||||
for ($i = $year; $i > 2012; $i--) {
|
||||
$awardeesMenu->addChild($i, [
|
||||
'uri' => $this->getUriFromRouter('awardees-by-year', ['year' => $i])
|
||||
$years = array_unique(array_map(function ($item) {
|
||||
return $item['year'];
|
||||
}, $result));
|
||||
|
||||
foreach ($years as $year) {
|
||||
$awardeesMenu->addChild($year, [
|
||||
'uri' => $this->getUriFromRouter('awardees-by-year', ['year' => $year])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Plates;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Zend\Expressive\Plates\Exception\MissingHelperException;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
@@ -21,6 +22,7 @@ class NavigationExtensionFactory
|
||||
}
|
||||
|
||||
$router = $container->get(RouterInterface::class);
|
||||
return new NavigationExtension($router);
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
return new NavigationExtension($router, $entityManager);
|
||||
}
|
||||
}
|
||||
|
||||
51
src/App/Plates/StringExtension.php
Normal file
51
src/App/Plates/StringExtension.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Plates;
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use League\Plates\Engine;
|
||||
use League\Plates\Extension\ExtensionInterface;
|
||||
|
||||
class StringExtension implements ExtensionInterface
|
||||
{
|
||||
/** @var CommonMarkConverter */
|
||||
private $converter;
|
||||
|
||||
public function __construct(CommonMarkConverter $converter)
|
||||
{
|
||||
$this->converter = $converter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register functions with the Plates engine.
|
||||
*
|
||||
* Registers:
|
||||
*
|
||||
* - mdtohtml(string $markdown) : string
|
||||
* - excerpt(string $text, int $length) : string
|
||||
*
|
||||
* @param Engine $engine
|
||||
*/
|
||||
public function register(Engine $engine): void
|
||||
{
|
||||
$engine->registerFunction('mdtohtml', [$this, 'markdownToHtml']);
|
||||
$engine->registerFunction('excerpt', [$this, 'excerpt']);
|
||||
}
|
||||
|
||||
public function markdownToHtml(string $markdown): string
|
||||
{
|
||||
return $this->converter->convertToHtml($markdown);
|
||||
}
|
||||
|
||||
|
||||
public function excerpt(string $text, int $length = 190): string
|
||||
{
|
||||
$length = abs((int)$length);
|
||||
if (strlen($text) > $length) {
|
||||
$text = preg_replace("/^(.{1,$length})(\s.*|$)/s", '\\1...', $text);
|
||||
}
|
||||
return($text);
|
||||
}
|
||||
}
|
||||
17
src/App/Plates/StringExtensionFactory.php
Normal file
17
src/App/Plates/StringExtensionFactory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Plates;
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class StringExtensionFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : StringExtension
|
||||
{
|
||||
$converter = new CommonMarkConverter();
|
||||
return new StringExtension($converter);
|
||||
}
|
||||
}
|
||||
43
src/App/Service/AwardeeManager.php
Normal file
43
src/App/Service/AwardeeManager.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Awardee;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class AwardeeManager
|
||||
{
|
||||
/** @var EntityManager */
|
||||
private $entityManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @return Awardee[]
|
||||
*/
|
||||
public function getJudgesByYear(int $year): ?array
|
||||
{
|
||||
return $this->entityManager->getRepository(Awardee::class)->findBy([
|
||||
'year' => $year,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $slug
|
||||
* @return Awardee|null
|
||||
*/
|
||||
public function getJudgeFromSlug(string $slug): ?Awardee
|
||||
{
|
||||
/** @var Awardee $awardee */
|
||||
$awardee = $this->entityManager->getRepository(Awardee::class)->findOneBy([
|
||||
'slug' => $slug,
|
||||
]);
|
||||
return $awardee;
|
||||
}
|
||||
}
|
||||
17
src/App/Service/AwardeeManagerFactory.php
Normal file
17
src/App/Service/AwardeeManagerFactory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class AwardeeManagerFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container) : AwardeeManager
|
||||
{
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
return new AwardeeManager($entityManager);
|
||||
}
|
||||
}
|
||||
121
src/App/Service/JudgeManager.php
Normal file
121
src/App/Service/JudgeManager.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
class JudgeManager
|
||||
{
|
||||
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' => '',
|
||||
// 'name' => 'Dr Viktor Łuszcz',
|
||||
// 'desc' => 'Hungarian Intellectual Property Office, President',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user