blob: 09baea730ba9003016cb17791906a747357f1f9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
namespace JsonApi\Routes\Consultations;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;
use JsonApi\Schemas\ConsultationBlock;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class BlockShow extends JsonApiController
{
protected $allowedIncludePaths = [
ConsultationBlock::REL_SLOTS,
ConsultationBlock::REL_RANGE,
];
public function __invoke(Request $request, Response $response, $args)
{
$block = \ConsultationBlock::find($args['id']);
if (!$block) {
throw new RecordNotFoundException();
}
if (!Authority::canShowBlock($this->getUser($request), $block)) {
throw new AuthorizationFailedException();
}
return $this->getContentResponse($block);
}
}
|