Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 55 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ConfigInfo | |
0.00% |
0 / 55 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| readResponse | |
0.00% |
0 / 55 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Zmsentities\Process; |
| 11 | use BO\Zmsentities\Collection\ProcessList; |
| 12 | use BO\Zmsentities\Request; |
| 13 | use BO\Zmsentities\Scope; |
| 14 | use BO\Zmsentities\Exception\UserAccountMissingRights; |
| 15 | |
| 16 | class ConfigInfo extends BaseController |
| 17 | { |
| 18 | /** |
| 19 | * @SuppressWarnings(Param) |
| 20 | * @return \Psr\Http\Message\ResponseInterface |
| 21 | */ |
| 22 | #[\Override] |
| 23 | public function readResponse( |
| 24 | \Psr\Http\Message\RequestInterface $request, |
| 25 | \Psr\Http\Message\ResponseInterface $response, |
| 26 | array $args |
| 27 | ): \Psr\Http\Message\ResponseInterface { |
| 28 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 29 | if (!$workstation->getUseraccount()->hasPermissions(['config'])) { |
| 30 | throw new UserAccountMissingRights(); |
| 31 | } |
| 32 | $config = \App::$http->readGetResult('/config/')->getEntity(); |
| 33 | |
| 34 | $mailtemplates = \App::$http->readGetResult('/mailtemplates/')->getCollection(); |
| 35 | |
| 36 | $mainProcessExample = ((new Process())->getExample()); |
| 37 | $mainProcessExample->id = 987654; |
| 38 | $dateTime = new \DateTimeImmutable("2015-10-23 08:00:00", new \DateTimeZone('Europe/Berlin')); |
| 39 | $mainProcessExample->getFirstAppointment()->setDateTime($dateTime); |
| 40 | $mainProcessExample->requests[] = (new Request())->getExample(); |
| 41 | |
| 42 | $processExample = ((new Process())->getExample()); |
| 43 | $processExample->scope = ((new Scope())->getExample()); |
| 44 | $processExample2 = clone $processExample; |
| 45 | $dateTime = new \DateTimeImmutable("2015-12-30 11:55:00", new \DateTimeZone('Europe/Berlin')); |
| 46 | $processExample2->getFirstAppointment()->setDateTime($dateTime); |
| 47 | |
| 48 | $processListExample = new ProcessList(); |
| 49 | $processListExample->addEntity($processExample); |
| 50 | $processListExample->addEntity($processExample2); |
| 51 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
| 52 | |
| 53 | if ($request->getMethod() === 'POST') { |
| 54 | $input = $request->getParsedBody(); |
| 55 | $entity = clone $config; |
| 56 | $entity->setPreference($input['key'], $input['property'], $input['value']); |
| 57 | \App::$http->readPostResult( |
| 58 | '/config/', |
| 59 | $entity |
| 60 | )->getEntity(); |
| 61 | return \BO\Slim\Render::redirect( |
| 62 | 'configinfo', |
| 63 | array( |
| 64 | 'title' => 'Konfiguration System', |
| 65 | 'workstation' => $workstation, |
| 66 | 'config' => $config, |
| 67 | 'processExample' => $mainProcessExample, |
| 68 | 'processListExample' => $processListExample, |
| 69 | 'menuActive' => 'configinfo' |
| 70 | ), |
| 71 | array( |
| 72 | 'success' => 'config_saved' |
| 73 | ) |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | return \BO\Slim\Render::withHtml( |
| 78 | $response, |
| 79 | 'page/configinfo.twig', |
| 80 | array( |
| 81 | 'title' => 'Konfiguration System', |
| 82 | 'workstation' => $workstation, |
| 83 | 'config' => $config, |
| 84 | 'mailtemplates' => $mailtemplates, |
| 85 | 'processExample' => $mainProcessExample, |
| 86 | 'processListExample' => $processListExample, |
| 87 | 'menuActive' => 'configinfo', |
| 88 | 'success' => $success |
| 89 | ) |
| 90 | ); |
| 91 | } |
| 92 | } |