Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DepartmentWorkstationList
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @package ZMS API
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsbackend\Department\Api;
9
10use BO\Slim\Render;
11use BO\Mellon\Validator;
12use BO\Zmsbackend\Workstation\Service\Workstation;
13use Psr\Http\Message\RequestInterface;
14use Psr\Http\Message\ResponseInterface;
15
16class DepartmentWorkstationList extends \BO\Zmsbackend\Api\BaseController
17{
18    #[\Override]
19    public function readResponse(
20        RequestInterface $request,
21        ResponseInterface $response,
22        array $args
23    ): ResponseInterface {
24        (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('useraccount');
25
26        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(1)->getValue();
27        $department = \BO\Zmsbackend\Helper\User::checkDepartment($args['id']);
28
29        $workstationList = (new \BO\Zmsbackend\Workstation\Service\Workstation())->readCollectionByDepartmentId($department->id, $resolveReferences);
30        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
31        $message->data = $workstationList;
32
33        $response = Render::withLastModified($response, time(), '0');
34
35        return Render::withJson($response, $message, 200);
36    }
37}