Fixes for controllers

This commit is contained in:
Mal 2020-08-21 22:47:49 +02:00
parent 3a99e99130
commit f4fdf50288
2 changed files with 12 additions and 3 deletions

View File

@ -5,6 +5,9 @@ declare(strict_types=1);
final class FingerprintPutController extends AbstractController
{
protected string $route = '/api/v1/fingerprint/{fingerprintId}';
protected array $mandatoryAttributes = [
'fingerprint',
];
private int $fingerprintId;

View File

@ -17,9 +17,15 @@ final class UserGetController extends AbstractController
public function handle(): void
{
$user = new User($this->userId);
$this->response = new ApiJsonResponse();
try {
$user = new User($this->userId);
$this->response->setResult($user);
} catch (Throwable $e) {
$this->response->setParameter('success', false);
$this->response->setStatus($e->getCode() !== 0 ? $e->getCode() : ServerStatus::INTERNAL_ERROR);
$this->response->setMessage($e->getMessage());
}
}
}