Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Status
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
3.00
0.00% covered (danger)
0.00%
0 / 1
 readResponse
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
3.00
1<?php
2
3/**
4 *
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 *
7 */
8
9namespace BO\Zmsstatistic;
10
11use BO\Slim\Render;
12use BO\Zmsentities\Exception\UserAccountMissingLogin;
13use Psr\Http\Message\RequestInterface;
14use Psr\Http\Message\ResponseInterface;
15
16/**
17 * Handle requests concerning services
18 */
19class Status extends BaseController
20{
21    protected $withAccess = false;
22
23    private const array MISSING_LOGIN_TEMPLATES = [
24        'BO\\Zmsentities\\Exception\\UserAccountMissingLogin',
25        'BO\\Zmsbackend\\Workstation\\Exception\\WorkstationNotFound',
26    ];
27
28    /**
29     * @SuppressWarnings(UnusedFormalParameter)
30     * @return ResponseInterface
31     */
32    #[\Override]
33    public function readResponse(
34        RequestInterface $request,
35        ResponseInterface $response,
36        array $args
37    ) {
38        try {
39            $workstation = \App::$http->readGetResult('/workstation/')->getEntity();
40        } catch (\BO\Zmsclient\Exception $exception) {
41            if (in_array($exception->template, self::MISSING_LOGIN_TEMPLATES, true)) {
42                throw new UserAccountMissingLogin();
43            }
44            throw $exception;
45        }
46
47        $result = \App::$http->readGetResult('/status/');
48        return Render::withHtml(
49            $response,
50            'page/status.twig',
51            array(
52                'title' => 'Status der Terminvereinbarung',
53                'workstation' => $workstation,
54                'status' => $result->getEntity(),
55                'isSuperuser' => $workstation->getUseraccount()->isSuperUser(),
56            )
57        );
58    }
59}