Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
97.50% covered (success)
97.50%
39 / 40
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TicketprinterConfig
97.50% covered (success)
97.50%
39 / 40
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 readResponse
97.50% covered (success)
97.50%
39 / 40
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Mellon\Validator;
11use BO\Zmsdb\Request;
12use BO\Zmsentities\Collection\RequestList;
13use BO\Zmsentities\Department as DepartmentEntity;
14use BO\Zmsentities\Collection\DepartmentList;
15
16class TicketprinterConfig extends BaseController
17{
18    /**
19     * @SuppressWarnings(Param)
20     * @return String
21     */
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
28        $scopeId = Validator::value($workstation['scope']['id'])->isNumber()->getValue();
29        $config = \App::$http->readGetResult('/config/')->getEntity();
30        $organisation = \App::$http->readGetResult(
31            '/scope/' . $scopeId . '/organisation/',
32            ['resolveReferences' => 5]
33        )->getEntity();
34
35        $source = \App::$http->readGetResult(
36            '/source/',
37            ['resolveReferences' => 2]
38        )->getEntity();
39        $requestList = (new RequestList())->addData($source->requests);
40
41        $departments = new DepartmentList();
42
43        foreach ($organisation->departments as $departmentData) {
44            $department = (new DepartmentEntity($departmentData))->withCompleteScopeList();
45            foreach ($department->scopes as $scope) {
46                $scope->services = [];
47
48                if (! isset($scope->provider->data)) {
49                    continue;
50                }
51
52                foreach ($scope->provider->data['services'] as $serviceArray) {
53                    $service = $requestList->getEntity($serviceArray['service']);
54
55                    if (! $service) {
56                        continue;
57                    }
58
59                    $scope->services[] = [
60                        'id' => $scope->id . '-' . $service->id,
61                        'name' => $service->name
62                    ];
63                }
64            }
65            $departments->addEntity($department);
66        }
67        return \BO\Slim\Render::withHtml(
68            $response,
69            'page/ticketprinterConfig.twig',
70            array(
71                'title' => 'Anmeldung an Warteschlange',
72                'config' => $config->getArrayCopy(),
73                'organisation' => $organisation->getArrayCopy(),
74                'departments' => $departments->getArrayCopy(),
75                'workstation' => $workstation,
76                'menuActive' => 'ticketprinter'
77            )
78        );
79    }
80}