Lines
92.30%
24 / 26
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkstationProcessProcessing | 92.30% | 24 / 26 | 0.00% | 0 / 1 | 5.01 | 0.00% | 0 / 1 | |||
| readResponse | 92.30% | 24 / 26 | 0.00% | 0 / 1 | 5.01 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsadmin | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsadmin; | |
| 9 | ||
| 10 | use BO\Slim\Render; | |
| 11 | use BO\Zmsentities\Exception\WorkstationMissingAssignedProcess; | |
| 12 | use BO\Zmsentities\Process; | |
| 13 | use BO\Zmsentities\Workstation; | |
| 14 | ||
| 15 | class WorkstationProcessProcessing extends BaseController | |
| 16 | { | |
| 17 | /** | |
| 18 | * @SuppressWarnings(Param) | |
| 19 | * @return \Psr\Http\Message\ResponseInterface | |
| 20 | */ | |
| 21 | #[\Override] | |
| 22 | public function readResponse( | |
| 23 | \Psr\Http\Message\RequestInterface $request, | |
| 24 | \Psr\Http\Message\ResponseInterface $response, | |
| 25 | array $args | |
| 26 | ): \Psr\Http\Message\ResponseInterface { | |
| 27 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); | |
| 28 | if (!$workstation instanceof Workstation) { | |
| 29 | throw new WorkstationMissingAssignedProcess(); | |
| 30 | } | |
| 31 | if (! $workstation->process->hasId()) { | |
| 32 | throw new WorkstationMissingAssignedProcess(); | |
| 33 | } | |
| 34 | ||
| 35 | // Re-saving an already processing process resets showUpTime (Bearbeitungszeit). | |
| 36 | // Only transition called → processing here; otherwise just render the current view. | |
| 37 | if ($workstation->process->getStatus() !== 'processing') { | |
| 38 | $workstation->process->status = 'processing'; | |
| 39 | $workstation->process->parkedBy = null; | |
| 40 | $savedProcess = \App::$http->readPostResult( | |
| 41 | '/process/' . $workstation->process->id . '/' . $workstation->process->authKey . '/', | |
| 42 | $workstation->process, | |
| 43 | ['initiator' => 'admin'] | |
| 44 | )->getEntity(); | |
| 45 | if (!$savedProcess instanceof Process) { | |
| 46 | throw new WorkstationMissingAssignedProcess(); | |
| 47 | } | |
| 48 | $workstation->process = $savedProcess; | |
| 49 | } | |
| 50 | ||
| 51 | $validator = $request->getAttribute('validator'); | |
| 52 | $error = $validator->getParameter('error')->isString()->getValue(); | |
| 53 | ||
| 54 | return Render::withHtml( | |
| 55 | $response, | |
| 56 | 'block/process/info.twig', | |
| 57 | array( | |
| 58 | 'workstation' => $workstation, | |
| 59 | 'error' => $error | |
| 60 | ) | |
| 61 | ); | |
| 62 | } | |
| 63 | } |