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