Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
WorkstationProcessDelete | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
2 |
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 | |
15 | class WorkstationProcessDelete extends BaseController |
16 | { |
17 | /** |
18 | * @SuppressWarnings(Param) |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | \BO\Zmsdb\Connection\Select::getWriteConnection(); |
27 | $workstation = (new Helper\User($request, 2))->checkRights(); |
28 | if (! $workstation->process['id']) { |
29 | throw new Exception\Process\ProcessNotFound(); |
30 | } |
31 | $process = (new Query())->readEntity($workstation->process['id'], $workstation->process['authKey'], 1); |
32 | $process = (new Query())->updateEntity( |
33 | $process, |
34 | \App::$now, |
35 | 0, |
36 | $process->status, |
37 | $workstation->getUseraccount() |
38 | ); |
39 | $workstation->process->setStatusBySettings(); |
40 | (new Workstation())->writeRemovedProcess($workstation); |
41 | unset($workstation->process); |
42 | |
43 | $message = Response\Message::create($request); |
44 | $message->data = $workstation; |
45 | |
46 | $response = Render::withLastModified($response, time(), '0'); |
47 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
48 | return $response; |
49 | } |
50 | } |