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