Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Owner | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
3 | |
0.00% |
0 / 1 |
| readResponse | |
96.77% |
30 / 31 |
|
0.00% |
0 / 1 |
3 | |||
| 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\Mellon\Validator; |
| 13 | use BO\Zmsentities\Owner as Entity; |
| 14 | use BO\Zmsentities\Exception\UserAccountMissingRights; |
| 15 | use BO\Slim\Render; |
| 16 | |
| 17 | class Owner extends BaseController |
| 18 | { |
| 19 | /** |
| 20 | * |
| 21 | * @return \Psr\Http\Message\ResponseInterface |
| 22 | */ |
| 23 | #[\Override] |
| 24 | public function readResponse( |
| 25 | \Psr\Http\Message\RequestInterface $request, |
| 26 | \Psr\Http\Message\ResponseInterface $response, |
| 27 | array $args |
| 28 | ): \Psr\Http\Message\ResponseInterface { |
| 29 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 30 | if (!$workstation->getUseraccount()->hasPermissions(['jurisdiction'])) { |
| 31 | throw new UserAccountMissingRights(); |
| 32 | } |
| 33 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
| 34 | $entityId = Validator::value($args['id'])->isNumber()->getValue(); |
| 35 | $entity = \App::$http->readGetResult('/owner/' . $entityId . '/')->getEntity(); |
| 36 | |
| 37 | $input = $request->getParsedBody(); |
| 38 | if (array_key_exists('save', (array) $input)) { |
| 39 | $entity = (new Entity($input))->withCleanedUpFormData(); |
| 40 | $entity->id = $entityId; |
| 41 | \App::$http->readPostResult('/owner/' . $entity->id . '/', $entity) |
| 42 | ->getEntity(); |
| 43 | return Render::redirect( |
| 44 | 'owner', |
| 45 | [ |
| 46 | 'id' => $entityId |
| 47 | ], |
| 48 | [ |
| 49 | 'success' => 'owner_saved' |
| 50 | ] |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | return Render::withHtml( |
| 55 | $response, |
| 56 | 'page/owner.twig', |
| 57 | array( |
| 58 | 'title' => 'Kunde','workstation' => $workstation->getArrayCopy(),'menuActive' => 'owner', |
| 59 | 'owner' => $entity->getArrayCopy(), |
| 60 | 'workstation' => $workstation->getArrayCopy(), |
| 61 | 'success' => $success |
| 62 | ) |
| 63 | ); |
| 64 | } |
| 65 | } |