blob: 4da4493779cd005a5aae11694a2d348fedd8c22f (
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\Files;
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;
class TermsOfUseIndex extends JsonApiController
{
protected $allowedPagingParameters = ['offset', 'limit'];
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
*/
public function __invoke(Request $request, Response $response, $args)
{
if (!Authority::canIndexTermsOfUse($this->getUser($request))) {
throw new AuthorizationFailedException();
}
$terms = \ContentTermsOfUse::findBySql('1');
list($offset, $limit) = $this->getOffsetAndLimit();
return $this->getPaginatedContentResponse(
array_slice($terms, $offset, $limit),
count($terms)
);
}
}
|