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