blob: 3bdea93b2dab88af38ce1cf8cb1882fdbecfb19c (
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
|
<?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;
/**
* Löscht eine Studip-Nachricht.
*/
class CommentsShow extends JsonApiController
{
protected $allowedIncludePaths = ['author', 'news'];
public function __invoke(Request $request, Response $response, $args)
{
if (!$comment = \StudipComment::find($args['id'])) {
throw new RecordNotFoundException();
}
if (!Authority::canShowNews($this->getUser($request), $comment->news)) {
throw new AuthorizationFailedException();
}
return $this->getContentResponse($comment);
}
}
|