Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| WarehouseSubjectGet | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
2 | |||
| 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 | |
| 13 | class WarehouseSubjectGet extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @SuppressWarnings(Param) |
| 17 | * @return String |
| 18 | */ |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ) { |
| 24 | $workstation = (new Helper\User($request, 2))->checkRights('scope'); |
| 25 | $subject = Validator::value($args['subject'])->isString()->getValue(); |
| 26 | $exchangeClass = '\BO\Zmsdb\Exchange' . ucfirst($subject ?? ''); |
| 27 | if (! class_exists($exchangeClass)) { |
| 28 | throw new Exception\Warehouse\UnknownReportType(); |
| 29 | } |
| 30 | $subjectIdList = (new $exchangeClass())->readSubjectList(); |
| 31 | |
| 32 | $message = Response\Message::create($request); |
| 33 | $message->data = (new Helper\ExchangeAccessFilter($subjectIdList, $workstation)) |
| 34 | ->getFilteredEntity() |
| 35 | ->withLessData(); |
| 36 | |
| 37 | $response = Render::withLastModified($response, time(), '0'); |
| 38 | $response = Render::withJson($response, $message, $message->getStatuscode()); |
| 39 | return $response; |
| 40 | } |
| 41 | } |