Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
96.43% |
27 / 28 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| DepartmentAddScope | |
96.43% |
27 / 28 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| readResponse | |
96.43% |
27 / 28 |
|
0.00% |
0 / 1 |
6 | |||
| 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 | if (!$workstation->getUseraccount()->hasPermissions(['scope'])) { |
| 29 | throw new \BO\Zmsentities\Exception\UserAccountMissingRights(); |
| 30 | } |
| 31 | $departmentId = Validator::value($args['id'])->isNumber()->getValue(); |
| 32 | $department = \App::$http |
| 33 | ->readGetResult('/department/' . $departmentId . '/', ['resolveReferences' => 0])->getEntity(); |
| 34 | $organisation = \App::$http->readGetResult('/department/' . $departmentId . '/organisation/')->getEntity(); |
| 35 | $providerList = Helper\ProviderHandler::readProviderList($workstation->getScope()->getSource()); |
| 36 | $sourceList = $this->readSourceList(); |
| 37 | $input = $request->getParsedBody(); |
| 38 | |
| 39 | if (is_array($input) && array_key_exists('save', $input)) { |
| 40 | $result = $this->writeUpdatedEntity($input, $department->id); |
| 41 | if ($result instanceof Entity) { |
| 42 | $this->writeUploadedImage($request, $result->id, $input); |
| 43 | return \BO\Slim\Render::redirect('scope', ['id' => $result->id], [ |
| 44 | 'success' => 'scope_created' |
| 45 | ]); |
| 46 | } |
| 47 | } |
| 48 | return \BO\Slim\Render::withHtml($response, 'page/scope.twig', array( |
| 49 | 'title' => 'Standort', |
| 50 | 'action' => 'add', |
| 51 | 'menuActive' => 'owner', |
| 52 | 'workstation' => $workstation, |
| 53 | 'organisation' => $organisation, |
| 54 | 'department' => $department, |
| 55 | 'sourceList' => $sourceList, |
| 56 | 'exception' => (isset($result)) ? $result : null, |
| 57 | 'providerList' => $providerList |
| 58 | )); |
| 59 | } |
| 60 | } |