Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WorkstationProcessParked
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 readResponse
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
6
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 WorkstationProcessParked 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        $previousStatus = $process->status;
33        $workstation->process->setStatus("parked");
34        $workstation->process->setStatusBySettings();
35        $process = (new Query())->updateEntity(
36            $process,
37            \App::$now,
38            0,
39            $previousStatus,
40            $workstation->getUseraccount()
41        );
42        (new Workstation())->writeRemovedProcess($workstation);
43        unset($workstation->process);
44
45        $message = Response\Message::create($request);
46        $message->data = $workstation;
47
48        $response = Render::withLastModified($response, time(), '0');
49        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
50        return $response;
51    }
52}