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