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