blob: dc0164143c61206daeb216b146c4c96ecb5ca03d (
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\JsonApiController;
/*
* Get all global news
*/
class GlobalNewsShow extends JsonApiController
{
protected $allowedPagingParameters = ['offset', 'limit'];
protected $allowedIncludePaths = ['author', 'ranges'];
public function __invoke(Request $request, Response $response, $args)
{
if (!$news = \StudipNews::getNewsByRange('studip', true, true)) {
$news = [];
}
list($offset, $limit) = $this->getOffsetAndLimit();
return $this->getPaginatedContentResponse(
array_slice($news, $offset, $limit),
count($news)
);
}
}
|