32 lines
990 B
PHP
32 lines
990 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
final class FingerprintGetController extends AbstractController
|
||
|
{
|
||
|
protected string $route = '/api/v1/fingerprint/{fingerprintId}';
|
||
|
|
||
|
private int $fingerprintId;
|
||
|
|
||
|
public function __construct(string $url)
|
||
|
{
|
||
|
parent::__construct($url);
|
||
|
|
||
|
$this->fingerprintId = (int)$this->getUrlParamInt('fingerprintId');
|
||
|
}
|
||
|
|
||
|
public function handle(): void
|
||
|
{
|
||
|
try {
|
||
|
$fingerprint = new Fingerprint($this->fingerprintId);
|
||
|
|
||
|
$this->response = new ApiJsonResponse();
|
||
|
$this->response->setResult($fingerprint->jsonSerialize());
|
||
|
} catch (Throwable $e) {
|
||
|
$this->response = new ApiJsonResponse(ApiResponse::STATUS_NOT_FOUND);
|
||
|
$this->response->setParameter('success', false);
|
||
|
$this->response->setMessage(sprintf('No fingerprint with id %d found!', $this->fingerprintId));
|
||
|
$this->response->setMimeType(ApiResponse::MIME_TYPE_JSON);
|
||
|
}
|
||
|
}
|
||
|
}
|