Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
78.95% |
30 / 38 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WorkstationProcessCalled | |
78.95% |
30 / 38 |
|
0.00% |
0 / 1 |
10.93 | |
0.00% |
0 / 1 |
| readResponse | |
78.95% |
30 / 38 |
|
0.00% |
0 / 1 |
10.93 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Mellon\Validator; |
| 11 | |
| 12 | class WorkstationProcessCalled extends BaseController |
| 13 | { |
| 14 | /** |
| 15 | * @return String |
| 16 | */ |
| 17 | public function readResponse( |
| 18 | \Psr\Http\Message\RequestInterface $request, |
| 19 | \Psr\Http\Message\ResponseInterface $response, |
| 20 | array $args |
| 21 | ) { |
| 22 | $validator = $request->getAttribute('validator'); |
| 23 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 24 | $processId = Validator::value($args['id'])->isNumber()->getValue(); |
| 25 | if (! $workstation->process->hasId() && ! $workstation->process->queue->callTime) { |
| 26 | $process = \App::$http->readGetResult('/process/' . $args['id'] . '/')->getEntity(); |
| 27 | try { |
| 28 | $workstation = \App::$http->readPostResult('/workstation/process/called/', $process, [ |
| 29 | 'allowClusterWideCall' => \App::$allowClusterWideCall |
| 30 | ])->getEntity(); |
| 31 | } catch (\BO\Zmsclient\Exception $e) { |
| 32 | if ($e->template === 'BO\\Zmsapi\\Exception\\Process\\ProcessAlreadyCalled') { |
| 33 | return \BO\Slim\Render::redirect( |
| 34 | 'workstationProcessCalled', |
| 35 | ['id' => $processId], |
| 36 | ['error' => 'has_called_process'] |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | throw $e; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | $excludedIds = $validator->getParameter('exclude')->isString()->setDefault('')->getValue(); |
| 45 | if ($excludedIds) { |
| 46 | $exclude = explode(',', $excludedIds); |
| 47 | } |
| 48 | $exclude[] = $workstation->process->toQueue(\App::$now)->number; |
| 49 | |
| 50 | $error = $validator->getParameter('error')->isString()->getValue(); |
| 51 | if (isset($processId) && $workstation->process->getId() != $processId) { |
| 52 | $error = 'has_called_process'; |
| 53 | } |
| 54 | |
| 55 | if ($workstation->process->getStatus() == 'processing') { |
| 56 | return \BO\Slim\Render::redirect('workstationProcessProcessing', [], ['error' => $error]); |
| 57 | } |
| 58 | |
| 59 | // Check if $process is set or assign a default value (like null) |
| 60 | $process = isset($process) ? $process : null; |
| 61 | |
| 62 | return \BO\Slim\Render::withHtml( |
| 63 | $response, |
| 64 | 'block/process/called.twig', |
| 65 | array( |
| 66 | 'title' => 'Sachbearbeiter', |
| 67 | 'workstation' => $workstation, |
| 68 | 'menuActive' => 'workstation', |
| 69 | 'process' => $process, |
| 70 | 'exclude' => join(',', $exclude), |
| 71 | 'error' => $error |
| 72 | ) |
| 73 | ); |
| 74 | } |
| 75 | } |