Lines
90.00%
18 / 20
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Status | 90.00% | 18 / 20 | 0.00% | 0 / 1 | 5.03 | 0.00% | 0 / 1 | |||
| readResponse | 90.00% | 18 / 20 | 0.00% | 0 / 1 | 5.03 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | * | |
| 7 | */ | |
| 8 | ||
| 9 | namespace BO\Zmsadmin; | |
| 10 | ||
| 11 | use BO\Zmsentities\Exception\UserAccountMissingLogin; | |
| 12 | use BO\Zmsentities\Workstation; | |
| 13 | ||
| 14 | /** | |
| 15 | * Handle requests concerning services | |
| 16 | */ | |
| 17 | class 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 | $isSuperuser = $workstation->getUseraccount()->isSuperUser(); | |
| 49 | return \BO\Slim\Render::withHtml( | |
| 50 | $response, | |
| 51 | 'page/status.twig', | |
| 52 | array( | |
| 53 | 'title' => 'Status der Terminvereinbarung', | |
| 54 | 'status' => $result->getEntity(), | |
| 55 | 'workstation' => $workstation, | |
| 56 | 'isSuperuser' => $isSuperuser, | |
| 57 | 'phpVersion' => $isSuperuser ? PHP_VERSION : null, | |
| 58 | ) | |
| 59 | ); | |
| 60 | } | |
| 61 | } |