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