Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ConflictListByScope | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
4 |
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 | use BO\Zmsdb\Scope; |
14 | |
15 | class ConflictListByScope extends BaseController |
16 | { |
17 | /** |
18 | * @SuppressWarnings(Param) |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | (new Helper\User($request))->checkRights('basic'); |
27 | $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(1)->getValue(); |
28 | |
29 | $startDateFormatted = Validator::param('startDate')->isString()->getValue(); |
30 | $endDateFormatted = Validator::param('endDate')->isString()->getValue(); |
31 | $startDate = ($startDateFormatted) ? new \BO\Zmsentities\Helper\DateTime($startDateFormatted) : \App::$now; |
32 | $endDate = ($endDateFormatted) ? new \BO\Zmsentities\Helper\DateTime($endDateFormatted) : \App::$now; |
33 | |
34 | $scope = (new Scope())->readEntity($args['id'], 1); |
35 | if (!$scope) { |
36 | throw new Exception\Scope\ScopeNotFound(); |
37 | } |
38 | |
39 | $conflictList = (new Process())->readConflictListByScopeAndTime( |
40 | $scope, |
41 | $startDate, |
42 | $endDate, |
43 | \App::$now, |
44 | $resolveReferences |
45 | ); |
46 | |
47 | $message = Response\Message::create($request); |
48 | $message->data = $conflictList; |
49 | |
50 | $response = Render::withLastModified($response, time(), '0'); |
51 | $response = Render::withJson($response, $message, 200); |
52 | return $response; |
53 | } |
54 | } |