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