* 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user