blob: f8c9c2fc9b0555ced72778dd741098e7ca4ec8b3 (
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
32
33
|
<?php
namespace JsonApi\Routes\News;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;
/*
* Get a single news by id
*/
class NewsShow extends JsonApiController
{
protected $allowedIncludePaths = ['author', 'ranges'];
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
*/
public function __invoke(Request $request, Response $response, $args)
{
if (!$news = \StudipNews::find($args['id'])) {
throw new RecordNotFoundException();
}
if (!Authority::canShowNews($this->getUser($request), $news)) {
throw new AuthorizationFailedException();
}
return $this->getContentResponse($news);
}
}
|