Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.83% covered (success)
95.83%
23 / 24
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
OwnerAddOrganisation
95.83% covered (success)
95.83%
23 / 24
0.00% covered (danger)
0.00%
0 / 1
4
0.00% covered (danger)
0.00%
0 / 1
 readResponse
95.83% covered (success)
95.83%
23 / 24
0.00% covered (danger)
0.00%
0 / 1
4
1<?php
2
3/**
4 * @package 115Mandant
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsentities\Exception\UserAccountMissingRights;
11use BO\Zmsentities\Organisation as Entity;
12use BO\Mellon\Validator;
13
14class 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}