Lines
88.88%
16 / 18
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Status | 88.88% | 16 / 18 | 0.00% | 0 / 1 | 4.02 | 0.00% | 0 / 1 | |||
| readResponse | 88.88% | 16 / 18 | 0.00% | 0 / 1 | 4.02 | |||||
| 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 | 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 | } |