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