Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
38 / 38 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TicketprinterConfig | |
100.00% |
38 / 38 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
38 / 38 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Mellon\Validator; |
| 11 | use BO\Zmsdb\Request; |
| 12 | use BO\Zmsentities\Collection\RequestList; |
| 13 | use BO\Zmsentities\Department as DepartmentEntity; |
| 14 | use BO\Zmsentities\Collection\DepartmentList; |
| 15 | |
| 16 | class TicketprinterConfig extends BaseController |
| 17 | { |
| 18 | /** |
| 19 | * @SuppressWarnings(Param) |
| 20 | * @return String |
| 21 | */ |
| 22 | public function readResponse( |
| 23 | \Psr\Http\Message\RequestInterface $request, |
| 24 | \Psr\Http\Message\ResponseInterface $response, |
| 25 | array $args |
| 26 | ) { |
| 27 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 28 | $scopeId = Validator::value($workstation['scope']['id'])->isNumber()->getValue(); |
| 29 | $config = \App::$http->readGetResult('/config/')->getEntity(); |
| 30 | $organisation = \App::$http->readGetResult( |
| 31 | '/scope/' . $scopeId . '/organisation/', |
| 32 | ['resolveReferences' => 5] |
| 33 | )->getEntity(); |
| 34 | |
| 35 | $source = \App::$http->readGetResult( |
| 36 | '/source/', |
| 37 | ['resolveReferences' => 2] |
| 38 | )->getEntity(); |
| 39 | $requestList = (new RequestList())->addData($source->requests); |
| 40 | |
| 41 | $departments = new DepartmentList(); |
| 42 | |
| 43 | foreach ($organisation->departments as $departmentData) { |
| 44 | $department = (new DepartmentEntity($departmentData))->withCompleteScopeList(); |
| 45 | foreach ($department->scopes as $scope) { |
| 46 | $scope->services = []; |
| 47 | |
| 48 | if (! isset($scope->provider->data)) { |
| 49 | continue; |
| 50 | } |
| 51 | |
| 52 | foreach ($scope->provider->data['services'] as $serviceArray) { |
| 53 | $service = $requestList->getEntity($serviceArray['service']); |
| 54 | $scope->services[] = [ |
| 55 | 'id' => $scope->id . '-' . $service->id, |
| 56 | 'name' => $service->name |
| 57 | ]; |
| 58 | } |
| 59 | } |
| 60 | $departments->addEntity($department); |
| 61 | } |
| 62 | return \BO\Slim\Render::withHtml( |
| 63 | $response, |
| 64 | 'page/ticketprinterConfig.twig', |
| 65 | array( |
| 66 | 'title' => 'Anmeldung an Warteschlange', |
| 67 | 'config' => $config->getArrayCopy(), |
| 68 | 'organisation' => $organisation->getArrayCopy(), |
| 69 | 'departments' => $departments->getArrayCopy(), |
| 70 | 'workstation' => $workstation, |
| 71 | 'menuActive' => 'ticketprinter' |
| 72 | ) |
| 73 | ); |
| 74 | } |
| 75 | } |