Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 49
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WorkstationProcessRedirect
0.00% covered (danger)
0.00%
0 / 49
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 readResponse
0.00% covered (danger)
0.00%
0 / 49
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsentities\Helper\ProcessPlainText;
11use Psr\Http\Message\RequestInterface;
12
13class WorkstationProcessRedirect extends BaseController
14{
15    /**
16     * @SuppressWarnings(Param)
17     * @return String
18     */
19    public function readResponse(
20        RequestInterface $request,
21        \Psr\Http\Message\ResponseInterface $response,
22        array $args
23    ) {
24        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity();
25        $department = \App::$http
26            ->readGetResult(
27                '/scope/' . $workstation->scope['id'] . '/department/',
28                ['resolveReferences' => 2]
29            )->getEntity();
30        $input = $request->getParsedBody();
31        $process = $workstation->process;
32
33        if ($request->getMethod() === 'POST') {
34            $validator = $request->getAttribute('validator');
35            $selectedLocation = $validator->getParameter('location')->isNumber()->getValue();
36
37            if (empty($selectedLocation)) {
38                return \BO\Slim\Render::redirect(
39                    'workstationProcessRedirect',
40                    [],
41                    [
42                        'errors' => [
43                            'location' => 'Bitte wählen Sie einen Standort aus.'
44                        ]
45                    ]
46                );
47            }
48
49            $scope = \App::$http
50                ->readGetResult(
51                    '/scope/' . $selectedLocation . '/',
52                    ['resolveReferences' => 2]
53                )->getEntity();
54
55            $newProcess = clone $process;
56            $newProcess->scope = $scope;
57            $newProcess->appointments[0]->scope = $scope;
58            $newProcess->amendment = ProcessPlainText::normalize($input['amendment'] ?? '');
59
60            $process = \App::$http->readPostResult('/process/status/redirect/', $newProcess)->getEntity();
61
62            return \BO\Slim\Render::redirect(
63                $workstation->getVariantName(),
64                array(),
65                array()
66            );
67        }
68
69        return \BO\Slim\Render::withHtml(
70            $response,
71            'page/workstationProcessRedirect.twig',
72            array(
73                'title' => 'Kundendaten',
74                'workstation' => $workstation,
75                'department' => $department,
76                'scope' => $workstation->scope,
77                'scopes' => $department->getScopeList(),
78                'menuActive' => 'workstation',
79                'errors' => $request->getParam('errors') ?? null
80            )
81        );
82    }
83}