* kanban service and stuff
This commit is contained in:
44
src/App/Handler/AvatarHandler.php
Normal file
44
src/App/Handler/AvatarHandler.php
Normal 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');
|
||||
}
|
||||
}
|
||||
22
src/App/Handler/AvatarHandlerFactory.php
Normal file
22
src/App/Handler/AvatarHandlerFactory.php
Normal 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);
|
||||
}
|
||||
}
|
||||
40
src/App/Handler/KanbanHandler.php
Normal file
40
src/App/Handler/KanbanHandler.php
Normal 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);
|
||||
}
|
||||
}
|
||||
22
src/App/Handler/KanbanHandlerFactory.php
Normal file
22
src/App/Handler/KanbanHandlerFactory.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user