Lines 100.00% 33 / 33
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 30 / 30 100.00% 1 / 1 2
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
14class WorkstationProcessParked extends \BO\Zmsbackend\Api\BaseController
15{
16    /**
17     * @SuppressWarnings(Param)
18     * @return \Psr\Http\Message\ResponseInterface
19     */
20    #[\Override]
21    public function readResponse(
22        \Psr\Http\Message\RequestInterface $request,
23        \Psr\Http\Message\ResponseInterface $response,
24        array $args
25    ) {
26        \BO\Zmsbackend\Connection\Select::getWriteConnection();
27        $workstation = (new \BO\Zmsbackend\Helper\User($request, 2))->checkPermissions();
28        if (! $workstation->process['id']) {
29            throw new \BO\Zmsbackend\Process\Exception\ProcessNotFound();
30        }
31        $process = (new Query())->readEntity($workstation->process['id'], $workstation->process['authKey'], 1);
32        $previousStatus = $process->status;
33        $workstation->process->setParkedBy($workstation->name);
34        $process->parkedBy = $workstation->name;
35        $workstation->process->setStatus("parked");
36        $process->status = \BO\Zmsentities\Process::STATUS_PARKED;
37        $workstation->process->setStatusBySettings();
38        $process = (new Query())->updateEntity(
39            $process,
40            \App::$now,
41            0,
42            $previousStatus,
43            $workstation->getUseraccount()
44        );
45        \App::$log->info('Process parked', [
46            'process_parked' => true,
47            'process_id' => $process->id,
48            'scope_id' => $process->scope['id']
49        ]);
50        (new \BO\Zmsbackend\Workstation\Service\Workstation())->writeRemovedProcess($workstation);
51        unset($workstation->process);
52
53        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
54        $message->data = $workstation;
55
56        $response = Render::withLastModified($response, time(), '0');
57        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
58        return $response;
59    }
60}

Inherited from BO\Zmsbackend\Api\BaseController

20    public function __invoke(RequestInterface $request, ResponseInterface $response, array $args)
21    {
22        $request = $this->initRequest($request);
23        $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0');
24        return $this->readResponse($request, $noCacheResponse, $args);
25    }