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