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