Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Organisation
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsentities\Organisation as Entity;
11use BO\Mellon\Validator;
12
13/**
14  * Handle requests concerning services
15  *
16  */
17class Organisation extends BaseController
18{
19    /**
20     * @return String
21     */
22
23    public function readResponse(
24        \Psr\Http\Message\RequestInterface $request,
25        \Psr\Http\Message\ResponseInterface $response,
26        array $args
27    ) {
28        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
29        $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue();
30        $entityId = Validator::value($args['id'])->isNumber()->getValue();
31        $entity = \App::$http->readGetResult(
32            '/organisation/' . $entityId . '/',
33            ['resolveReferences' => 1]
34        )->getEntity();
35
36        $input = $request->getParsedBody();
37        if (array_key_exists('save', (array) $input)) {
38            $entity = (new Entity($input))->withCleanedUpFormData();
39            $entity->id = $entityId;
40            $entity = \App::$http->readPostResult('/organisation/' . $entity->id . '/', $entity)->getEntity();
41            return \BO\Slim\Render::redirect(
42                'organisation',
43                [
44                    'id' => $entityId
45                ],
46                [
47                    'success' => 'organisation_saved'
48                ]
49            );
50        }
51
52        return \BO\Slim\Render::withHtml(
53            $response,
54            'page/organisation.twig',
55            array(
56                'title' => 'Bezirk - Einrichtung und Administration',
57                'workstation' => $workstation,
58                'organisation' => $entity,
59                'menuActive' => 'owner',
60                'success' => $success
61            )
62        );
63    }
64}