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