Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
95.83% |
23 / 24 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OwnerAddOrganisation | |
95.83% |
23 / 24 |
|
0.00% |
0 / 1 |
4 | |
0.00% |
0 / 1 |
| readResponse | |
95.83% |
23 / 24 |
|
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\Organisation as Entity; |
| 11 | use BO\Mellon\Validator; |
| 12 | |
| 13 | class OwnerAddOrganisation extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @return \Psr\Http\Message\ResponseInterface |
| 17 | */ |
| 18 | #[\Override] |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ): \Psr\Http\Message\ResponseInterface { |
| 24 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 25 | if (!$workstation->getUseraccount()->hasPermissions(['organisation'])) { |
| 26 | throw new \BO\Zmsentities\Exception\UserAccountMissingRights(); |
| 27 | } |
| 28 | $input = $request->getParsedBody(); |
| 29 | $parentId = Validator::value($args['id'])->isNumber()->getValue(); |
| 30 | if (is_array($input) && array_key_exists('save', $input)) { |
| 31 | $entity = (new Entity($input))->withCleanedUpFormData(); |
| 32 | $entity = \App::$http->readPostResult('/owner/' . $parentId . '/organisation/', $entity) |
| 33 | ->getEntity(); |
| 34 | return \BO\Slim\Render::redirect( |
| 35 | 'organisation', |
| 36 | array( |
| 37 | 'id' => $entity->id |
| 38 | ), |
| 39 | array( |
| 40 | 'success' => 'organisation_created' |
| 41 | ) |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | return \BO\Slim\Render::withHtml($response, 'page/organisation.twig', array( |
| 46 | 'title' => 'Referat einrichten', |
| 47 | 'action' => 'add', |
| 48 | 'menuActive' => 'organisation', |
| 49 | 'workstation' => $workstation |
| 50 | )); |
| 51 | } |
| 52 | } |