Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Owner | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * |
5 | * @package Zmsadmin |
6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
7 | * |
8 | */ |
9 | |
10 | namespace BO\Zmsadmin; |
11 | |
12 | use BO\Zmsentities\Owner as Entity; |
13 | use BO\Mellon\Validator; |
14 | |
15 | class Owner extends BaseController |
16 | { |
17 | /** |
18 | * |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
27 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
28 | $entityId = Validator::value($args['id'])->isNumber()->getValue(); |
29 | $entity = \App::$http->readGetResult('/owner/' . $entityId . '/')->getEntity(); |
30 | |
31 | $input = $request->getParsedBody(); |
32 | if (array_key_exists('save', (array) $input)) { |
33 | $entity = (new Entity($input))->withCleanedUpFormData(); |
34 | $entity->id = $entityId; |
35 | $entity = \App::$http->readPostResult('/owner/' . $entity->id . '/', $entity) |
36 | ->getEntity(); |
37 | return \BO\Slim\Render::redirect( |
38 | 'owner', |
39 | [ |
40 | 'id' => $entityId |
41 | ], |
42 | [ |
43 | 'success' => 'owner_saved' |
44 | ] |
45 | ); |
46 | } |
47 | |
48 | return \BO\Slim\Render::withHtml( |
49 | $response, |
50 | 'page/owner.twig', |
51 | array( |
52 | 'title' => 'Kunde','workstation' => $workstation->getArrayCopy(),'menuActive' => 'owner', |
53 | 'owner' => $entity->getArrayCopy(), |
54 | 'workstation' => $workstation->getArrayCopy(), |
55 | 'success' => $success |
56 | ) |
57 | ); |
58 | } |
59 | } |