Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Process | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
3 | |
0.00% |
0 / 1 |
| readResponse | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsticketprinter |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsticketprinter; |
| 11 | |
| 12 | use BO\Slim\Render; |
| 13 | use BO\Zmsclient\Exception\BadRequest; |
| 14 | use BO\Zmsentities\Scope; |
| 15 | use Psr\Http\Message\RequestInterface; |
| 16 | use Psr\Http\Message\ResponseInterface; |
| 17 | use BO\Zmsticketprinter\Helper\QueueListHelper; |
| 18 | |
| 19 | class Process extends BaseController |
| 20 | { |
| 21 | /** |
| 22 | * @SuppressWarnings(UnusedFormalParameter) |
| 23 | * @return ResponseInterface |
| 24 | */ |
| 25 | public function readResponse( |
| 26 | RequestInterface $request, |
| 27 | ResponseInterface $response, |
| 28 | array $args |
| 29 | ) { |
| 30 | $ticketprinterHelper = (new Helper\Ticketprinter($args, $request)); |
| 31 | |
| 32 | $config = \App::$http->readGetResult('/config/', [], \App::SECURE_TOKEN)->getEntity(); |
| 33 | $validator = $request->getAttribute('validator'); |
| 34 | $scopeId = $validator->getParameter('scopeId')->isNumber()->getValue(); |
| 35 | $requestId = $validator->getParameter('requestId')->isNumber()->getValue(); |
| 36 | $printText = $validator->getParameter('printText')->isString()->getValue(); |
| 37 | if (null === $scopeId) { |
| 38 | throw new Exception\ScopeNotFound(); |
| 39 | } |
| 40 | |
| 41 | $process = \App::$http->readGetResult( |
| 42 | '/scope/' . $scopeId . '/waitingnumber/' . $ticketprinterHelper->getEntity()->hash . '/', |
| 43 | $requestId ? ['requestId' => $requestId] : null |
| 44 | )->getEntity(); |
| 45 | |
| 46 | $scope = new Scope($process->scope); |
| 47 | $department = \App::$http->readGetResult('/scope/' . $scope->getId() . '/department/')->getEntity(); |
| 48 | |
| 49 | $queueListHelper = (new QueueListHelper($scope, $process)); |
| 50 | |
| 51 | return Render::withHtml( |
| 52 | $response, |
| 53 | 'page/process.twig', |
| 54 | array( |
| 55 | 'debug' => \App::DEBUG, |
| 56 | 'title' => 'Anmeldung an der Warteschlange', |
| 57 | 'ticketprinter' => $ticketprinterHelper->getEntity(), |
| 58 | 'organisation' => $ticketprinterHelper->getOrganisation(), |
| 59 | 'process' => $process, |
| 60 | 'printText' => $printText, |
| 61 | 'waitingTime' => $queueListHelper->getEstimatedWaitingTime(), |
| 62 | 'waitingClients' => ($queueListHelper->getClientsBefore()), |
| 63 | 'config' => $config, |
| 64 | 'department' => $department |
| 65 | ) |
| 66 | ); |
| 67 | } |
| 68 | } |