38 lines
848 B
PHP
38 lines
848 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
final class SharingGetController extends AbstractController
|
||
|
{
|
||
|
protected string $route = '/api/v1/sharing/{sharingId}';
|
||
|
|
||
|
private int $sharingId;
|
||
|
|
||
|
public function __construct(string $url)
|
||
|
{
|
||
|
parent::__construct($url);
|
||
|
|
||
|
$this->sharingId = (int)$this->getUrlParamInt('sharingId');
|
||
|
}
|
||
|
|
||
|
public function handle(): void
|
||
|
{
|
||
|
parent::handle();
|
||
|
|
||
|
if ($this->response->getStatus() !== ServerStatus::OK) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
$sharing = new Sharing($this->sharingId);
|
||
|
|
||
|
$this->response = new ApiJsonResponse();
|
||
|
$this->response->setParameter('success', true);
|
||
|
$this->response->setResult($sharing);
|
||
|
} catch (Throwable $e) {
|
||
|
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
|
||
|
$this->response->setParameter('success', false);
|
||
|
$this->response->setMessage($e->getMessage());
|
||
|
}
|
||
|
}
|
||
|
}
|