blob: ce98f9a4e5bee5de2a2ca42df1adf72523641878 (
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
34
35
36
|
<?php
namespace JsonApi\Routes\Forum;
use JsonApi\Errors\RecordNotFoundException;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use JsonApi\JsonApiController;
use Forum\Subscription;
class SubscriptionShow extends JsonApiController
{
protected $allowedIncludePaths = [
\JsonApi\Schemas\Forum\Subscription::REL_RANGE,
\JsonApi\Schemas\Forum\Subscription::REL_SUBJECT,
\JsonApi\Schemas\Forum\Subscription::REL_USER,
];
public function __invoke(Request $request, Response $response, $args)
{
$user = $this->getUser($request);
$subscription = Subscription::findOneBySQL(
"id = :id AND user_id = :user_id",
[
'id' => $args['subscription_id'],
'user_id' => $user->user_id
]
);
if (!$subscription) {
throw new RecordNotFoundException();
}
return $this->getContentResponse($subscription);
}
}
|