Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
DepartmentAddScope | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
5 |
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\Scope as Entity; |
11 | use BO\Mellon\Validator; |
12 | |
13 | /** |
14 | * Handle requests concerning services |
15 | * |
16 | */ |
17 | class DepartmentAddScope extends Scope |
18 | { |
19 | /** |
20 | * @return String |
21 | */ |
22 | public function readResponse( |
23 | \Psr\Http\Message\RequestInterface $request, |
24 | \Psr\Http\Message\ResponseInterface $response, |
25 | array $args |
26 | ) { |
27 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
28 | $departmentId = Validator::value($args['id'])->isNumber()->getValue(); |
29 | $department = \App::$http |
30 | ->readGetResult('/department/' . $departmentId . '/', ['resolveReferences' => 0])->getEntity(); |
31 | $organisation = \App::$http->readGetResult('/department/' . $departmentId . '/organisation/')->getEntity(); |
32 | $providerList = Helper\ProviderHandler::readProviderList($workstation->getScope()->getSource()); |
33 | $sourceList = $this->readSourceList(); |
34 | $input = $request->getParsedBody(); |
35 | |
36 | if (is_array($input) && array_key_exists('save', $input)) { |
37 | $result = $this->testUpdateEntity($input, $department->id); |
38 | if ($result instanceof Entity) { |
39 | $this->writeUploadedImage($request, $result->id, $input); |
40 | return \BO\Slim\Render::redirect('scope', ['id' => $result->id], [ |
41 | 'success' => 'scope_created' |
42 | ]); |
43 | } |
44 | } |
45 | return \BO\Slim\Render::withHtml($response, 'page/scope.twig', array( |
46 | 'title' => 'Standort', |
47 | 'action' => 'add', |
48 | 'menuActive' => 'owner', |
49 | 'workstation' => $workstation, |
50 | 'organisation' => $organisation, |
51 | 'department' => $department, |
52 | 'sourceList' => $sourceList, |
53 | 'exception' => (isset($result)) ? $result : null, |
54 | 'providerList' => $providerList |
55 | )); |
56 | } |
57 | } |