* kanban service and stuff

This commit is contained in:
Dávid Danyi
2018-04-21 15:23:06 +02:00
parent b0295227bc
commit a43b5e9d09
25 changed files with 2071 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Service\AvatarService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response\TextResponse;
class AvatarHandler implements RequestHandlerInterface
{
/** @var AvatarService */
private $avatarService;
/**
* AvatarHandler constructor.
* @param AvatarService $avatarService
*/
public function __construct(AvatarService $avatarService)
{
$this->avatarService = $avatarService;
}
/**
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
$signum = $request->getAttribute('signum', false);
try {
$avatarImageData = $this->avatarService->getAvatarImageData($signum);
} catch (\UnexpectedValueException $e) {
return new TextResponse("Avatar not found", 404);
}
return (new TextResponse($avatarImageData, 200, [
'content-type' => 'image/png',
]))->withHeader('Expires', '0')
->withHeader('Cache-Control', 'must-revalidate');
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Service\AvatarService;
use Interop\Container\ContainerInterface;
class AvatarHandlerFactory
{
/**
* @param ContainerInterface $container
* @return AvatarHandler
*/
public function __invoke(ContainerInterface $container)
{
/** @var AvatarService $avatarService */
$avatarService = $container->get(AvatarService::class);
return new AvatarHandler($avatarService);
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Entity\KanbanBoard;
use App\Service\JiraCollectorService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response\JsonResponse;
class KanbanHandler implements RequestHandlerInterface
{
/** @var JiraCollectorService */
private $dataCollector;
/**
* KanbanAction constructor.
* @param JiraCollectorService $dataCollectorService
*/
public function __construct(JiraCollectorService $dataCollectorService)
{
$this->dataCollector = $dataCollectorService;
}
/**
* @param ServerRequestInterface $request
* @return ResponseInterface
* @todo filterId
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
$filterId = $request->getAttribute('filterId');
/** @var KanbanBoard $kanbanResult */
$kanbanResult = $this->dataCollector->getKanbanBoard($filterId);
return new JsonResponse($kanbanResult);
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Service\JiraCollectorService;
use Interop\Container\ContainerInterface;
class KanbanHandlerFactory
{
/**
* @param ContainerInterface $container
* @return KanbanHandler
*/
public function __invoke(ContainerInterface $container)
{
/** @var JiraCollectorService $dataCollectorService */
$dataCollectorService = $container->get(JiraCollectorService::class);
return new KanbanHandler($dataCollectorService);
}
}