Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Pickup | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | /** |
4 | * @package ZMS API |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsapi; |
9 | |
10 | use BO\Slim\Render; |
11 | use BO\Mellon\Validator; |
12 | use BO\Zmsdb\Process; |
13 | |
14 | class Pickup extends BaseController |
15 | { |
16 | /** |
17 | * @SuppressWarnings(Param) |
18 | * @return String |
19 | */ |
20 | public function readResponse( |
21 | \Psr\Http\Message\RequestInterface $request, |
22 | \Psr\Http\Message\ResponseInterface $response, |
23 | array $args |
24 | ) { |
25 | $workstation = (new Helper\User($request))->checkRights(); |
26 | $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(0)->getValue(); |
27 | $limit = Validator::param('limit')->isNumber()->setDefault(1000)->getValue(); |
28 | $offset = Validator::param('offset')->isNumber()->setDefault(null)->getValue(); |
29 | $selectedScope = Validator::param('selectedScope')->isNumber()->getValue(); |
30 | $scopeId = ($selectedScope) ? $selectedScope : $workstation->scope['id']; |
31 | $scope = (new \BO\Zmsdb\Scope())->readEntity($scopeId, 0); |
32 | if (! $scope) { |
33 | throw new Exception\Scope\ScopeNotFound(); |
34 | } |
35 | |
36 | $processList = (new Process())->readProcessListByScopeAndStatus( |
37 | $scope['id'], |
38 | 'pending', |
39 | $resolveReferences, |
40 | $limit, |
41 | $offset |
42 | ); |
43 | |
44 | $message = Response\Message::create($request); |
45 | $message->data = $processList; |
46 | |
47 | $response = Render::withLastModified($response, time(), '0'); |
48 | $response = Render::withJson($response, $message, 200); |
49 | return $response; |
50 | } |
51 | } |