31 lines
742 B
PHP
31 lines
742 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
final class UserSharingsGetController extends AbstractController
|
|
{
|
|
protected string $route = '/api/v1/user/{userId}/sharings';
|
|
|
|
private int $userId;
|
|
|
|
public function __construct(string $url)
|
|
{
|
|
parent::__construct($url);
|
|
|
|
$this->userId = (int)$this->getUrlParamInt('userId');
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$user = new User($this->userId);
|
|
|
|
try {
|
|
$this->response = new ApiJsonResponse();
|
|
$this->response->setParameter('sharings', $user->getSharings());
|
|
} catch (Throwable $e) {
|
|
$this->response = new ApiJsonResponse($e->getCode() !== 0 ? $e->getCode() : ServerStatus::BAD_REQUEST);
|
|
$this->response->setSuccess(false);
|
|
$this->response->setMessage($e->getMessage());
|
|
}
|
|
}
|
|
} |