Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
77.78% |
35 / 45 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Notification | |
77.78% |
35 / 45 |
|
0.00% |
0 / 1 |
4.18 | |
0.00% |
0 / 1 |
| readResponse | |
77.78% |
35 / 45 |
|
0.00% |
0 / 1 |
4.18 | |||
| 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 Psr\Http\Message\RequestInterface; |
| 14 | use Psr\Http\Message\ResponseInterface; |
| 15 | |
| 16 | class Notification extends BaseController |
| 17 | { |
| 18 | /** |
| 19 | * @SuppressWarnings(UnusedFormalParameter) |
| 20 | * @return ResponseInterface |
| 21 | */ |
| 22 | public function readResponse( |
| 23 | RequestInterface $request, |
| 24 | ResponseInterface $response, |
| 25 | array $args |
| 26 | ) { |
| 27 | $validator = $request->getAttribute('validator'); |
| 28 | $waitingNumber = $validator->getParameter('waitingNumber')->isNumber()->getValue(); |
| 29 | $hasProcess = $validator->getParameter('processWithNotifiation')->isNumber()->getValue(); |
| 30 | $scopeId = $validator->getParameter('scopeId')->isNumber()->getValue(); |
| 31 | if (null === $scopeId) { |
| 32 | throw new Exception\ScopeNotFound(); |
| 33 | } |
| 34 | $ticketprinterHelper = new Helper\Ticketprinter($args, $request); |
| 35 | |
| 36 | if (! $waitingNumber) { |
| 37 | return Render::redirect( |
| 38 | 'Message', |
| 39 | [ |
| 40 | 'status' => 'process_notification_amendment_waitingnumber_unvalid' |
| 41 | ], |
| 42 | [ |
| 43 | 'scopeId' => $scopeId, |
| 44 | 'notHome' => 1 |
| 45 | ] |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | $process = \App::$http |
| 50 | ->readGetResult('/scope/' . $scopeId . '/queue/' . $waitingNumber . '/') |
| 51 | ->getEntity(); |
| 52 | |
| 53 | if ($process->getFirstClient()->hasTelephone()) { |
| 54 | return Render::redirect( |
| 55 | 'Message', |
| 56 | [ |
| 57 | 'status' => 'process_notification_amendment_phonenumber_exists' |
| 58 | ], |
| 59 | [ |
| 60 | 'scopeId' => $scopeId, |
| 61 | 'notHome' => 1 |
| 62 | ] |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | return Render::withHtml( |
| 67 | $response, |
| 68 | 'page/notification.twig', |
| 69 | array( |
| 70 | 'debug' => \App::DEBUG, |
| 71 | 'hasProcess' => $hasProcess, |
| 72 | 'homeUrl' => \BO\Zmsclient\Ticketprinter::getHomeUrl(), |
| 73 | 'title' => 'Anmeldung an der Warteschlange', |
| 74 | 'ticketprinter' => $ticketprinterHelper->getEntity(), |
| 75 | 'organisation' => $ticketprinterHelper->getOrganisation(), |
| 76 | 'process' => $process |
| 77 | ) |
| 78 | ); |
| 79 | } |
| 80 | } |