Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WorkstationProcessDelete | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
4 | |
0.00% |
0 / 1 |
| readResponse | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ZMS API |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsapi; |
| 9 | |
| 10 | use BO\Slim\Render; |
| 11 | use BO\Mellon\Validator; |
| 12 | use BO\Zmsdb\Workstation; |
| 13 | use BO\Zmsdb\Process as Query; |
| 14 | use BO\Zmsentities\Process; |
| 15 | |
| 16 | class WorkstationProcessDelete extends BaseController |
| 17 | { |
| 18 | /** |
| 19 | * @SuppressWarnings(Param) |
| 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 | \BO\Zmsdb\Connection\Select::getWriteConnection(); |
| 28 | $workstation = (new Helper\User($request, 2))->checkRights(); |
| 29 | if (! $workstation->process['id']) { |
| 30 | throw new Exception\Process\ProcessNotFound(); |
| 31 | } |
| 32 | $process = (new Query())->readEntity($workstation->process['id'], $workstation->process['authKey'], 1); |
| 33 | if ('called' == $workstation->process->status && $workstation->process->queue['callCount'] > $workstation->scope->getPreference('queue', 'callCountMax')) { |
| 34 | $process->setWasMissed(true); |
| 35 | } |
| 36 | $process = (new Query())->updateEntity( |
| 37 | $process, |
| 38 | \App::$now, |
| 39 | 0, |
| 40 | $process->status, |
| 41 | $workstation->getUseraccount() |
| 42 | ); |
| 43 | $workstation->process->setStatusBySettings(); |
| 44 | (new Workstation())->writeRemovedProcess($workstation); |
| 45 | unset($workstation->process); |
| 46 | |
| 47 | $message = Response\Message::create($request); |
| 48 | $message->data = $workstation; |
| 49 | |
| 50 | $response = Render::withLastModified($response, time(), '0'); |
| 51 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
| 52 | return $response; |
| 53 | } |
| 54 | } |