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\Zmsadmin;
10
11use BO\Zmsentities\Exception\UserAccountMissingLogin;
12
13/**
14 * Handle requests concerning services
15 */
16class Status extends BaseController
17{
18    private const array MISSING_LOGIN_TEMPLATES = [
19        'BO\\Zmsentities\\Exception\\UserAccountMissingLogin',
20        'BO\\Zmsbackend\\Workstation\\Exception\\WorkstationNotFound',
21    ];
22
23    /**
24     * @SuppressWarnings(UnusedFormalParameter)
25     * @return \Psr\Http\Message\ResponseInterface
26     */
27    #[\Override]
28    public function readResponse(
29        \Psr\Http\Message\RequestInterface $request,
30        \Psr\Http\Message\ResponseInterface $response,
31        array $args
32    ): \Psr\Http\Message\ResponseInterface {
33        try {
34            $workstation = \App::$http->readGetResult('/workstation/')->getEntity();
35        } catch (\BO\Zmsclient\Exception $exception) {
36            if (in_array($exception->template, self::MISSING_LOGIN_TEMPLATES, true)) {
37                throw new UserAccountMissingLogin();
38            }
39            throw $exception;
40        }
41
42        $result = \App::$http->readGetResult('/status/');
43        return \BO\Slim\Render::withHtml(
44            $response,
45            'page/status.twig',
46            array(
47                'title' => 'Status der Terminvereinbarung',
48                'status' => $result->getEntity(),
49                'workstation' => $workstation,
50                'isSuperuser' => $workstation->getUseraccount()->isSuperUser(),
51            )
52        );
53    }
54}