Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WorkstationSelect | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
9 | |
0.00% |
0 / 1 |
| readResponse | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
9 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Zmsclient\ModuleAccess; |
| 11 | use BO\Zmsadmin\Helper\LoginForm; |
| 12 | use BO\Mellon\Validator; |
| 13 | |
| 14 | class WorkstationSelect extends BaseController |
| 15 | { |
| 16 | /** |
| 17 | * @SuppressWarnings(Parameter) |
| 18 | * @return \Psr\Http\Message\ResponseInterface |
| 19 | */ |
| 20 | #[\Override] |
| 21 | public function readResponse( |
| 22 | \Psr\Http\Message\RequestInterface $request, |
| 23 | \Psr\Http\Message\ResponseInterface $response, |
| 24 | array $args |
| 25 | ): \Psr\Http\Message\ResponseInterface { |
| 26 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 27 | if (!$workstation->hasId()) { |
| 28 | return \BO\Slim\Render::redirect('index', array('error' => 'login_failed')); |
| 29 | } |
| 30 | if ($wrongModuleResponse = ModuleAccess::rejectWrongModuleAccess(ModuleAccess::MODULE_ADMIN, $workstation, $response)) { |
| 31 | return $wrongModuleResponse; |
| 32 | } |
| 33 | |
| 34 | $input = $request->getParsedBody(); |
| 35 | $formData = []; |
| 36 | if (is_array($input) && (array_key_exists('scope', $input))) { |
| 37 | $form = LoginForm::fromAdditionalParameters(); |
| 38 | $formData = $form->getStatus(); |
| 39 | $selectedDate = Validator::param('selectedDate')->isString()->getValue(); |
| 40 | $queryParams = ($selectedDate) ? array('date' => $selectedDate) : array(); |
| 41 | $redirect = (array_key_exists('redirect', $input)) ? $input['redirect'] : null; |
| 42 | if (! $form->hasFailed()) { |
| 43 | LoginForm::writeWorkstationUpdate($form, $workstation); |
| 44 | return \BO\Slim\Render::redirect( |
| 45 | ($redirect) ? $redirect : $workstation->getVariantName(), |
| 46 | array(), |
| 47 | $queryParams |
| 48 | ); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return \BO\Slim\Render::withHtml( |
| 53 | $response, |
| 54 | 'page/workstationSelect.twig', |
| 55 | array( |
| 56 | 'title' => 'Standort und Arbeitsplatz auswählen', |
| 57 | 'advancedData' => $formData, |
| 58 | 'workstation' => $workstation, |
| 59 | 'menuActive' => 'select', |
| 60 | 'today' => \App::$now->format('Y-m-d') |
| 61 | ) |
| 62 | ); |
| 63 | } |
| 64 | } |