Lines 100.00% 13 / 13
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ProcessListByScopeAndStatus 100.00% 13 / 13 100.00% 1 / 1 2 100.00% 1 / 1
 readResponse 100.00% 13 / 13 100.00% 1 / 1 2
1<?php
2
3/**
4 * @package ZMS API
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsbackend\Process\Api;
9
10use BO\Slim\Render;
11use BO\Mellon\Validator;
12use BO\Zmsbackend\Process\Service\Process;
13use BO\Zmsbackend\Scope\Service\Scope;
14
15class ProcessListByScopeAndStatus extends \BO\Zmsbackend\Api\BaseController
16{
17    /**
18     * @SuppressWarnings(Param)
19     * @return \Psr\Http\Message\ResponseInterface
20     */
21    #[\Override]
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(0)->getValue();
28        $scope = (new \BO\Zmsbackend\Scope\Service\Scope())->readEntity($args['id'], $resolveReferences);
29        if (! $scope) {
30            throw new \BO\Zmsbackend\Scope\Exception\ScopeNotFound();
31        }
32
33        (new \BO\Zmsbackend\Helper\User($request, 2))->checkPermissions(
34            new \BO\Zmsentities\Useraccount\EntityAccess($scope)
35        );
36
37        $query = new \BO\Zmsbackend\Process\Service\Process();
38        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
39        $message->data = $query->readProcessListByScopeAndStatus($scope->id, $args['status'], $resolveReferences);
40
41        $response = Render::withLastModified($response, time(), '0');
42        $response = Render::withJson($response, $message, 200);
43        return $response;
44    }
45}