Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Useraccount
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
5
1<?php
2
3/**
4 *
5 * @package Zmsadmin
6 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
7 *
8 */
9
10namespace BO\Zmsadmin;
11
12use BO\Zmsentities\Collection\UseraccountList as Collection;
13use Psr\Http\Message\RequestInterface;
14use Psr\Http\Message\ResponseInterface;
15
16class Useraccount extends BaseController
17{
18    /**
19     * @SuppressWarnings(Param)
20     * @return ResponseInterface
21     */
22    public function readResponse(
23        RequestInterface $request,
24        ResponseInterface $response,
25        array $args
26    ) {
27        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
28        $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue();
29        $ownerList = \App::$http->readGetResult('/owner/', array('resolveReferences' => 2))->getCollection();
30
31        $useraccountList = new Collection();
32        if ($workstation->hasSuperUseraccount()) {
33            $useraccountList = \App::$http->readGetResult("/useraccount/", ["resolveReferences" => 0])->getCollection();
34        } else {
35            $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity();
36            $departmentList = $workstation->getUseraccount()->getDepartmentList();
37            foreach ($departmentList as $accountDepartment) {
38                $departmentUseraccountList = \App::$http
39                    ->readGetResult("/department/$accountDepartment->id/useraccount/")
40                    ->getCollection();
41                if ($departmentUseraccountList) {
42                    $useraccountList = $useraccountList->addList($departmentUseraccountList)->withoutDublicates();
43                }
44            }
45        }
46
47        return \BO\Slim\Render::withHtml(
48            $response,
49            'page/useraccount.twig',
50            array(
51                'title' => 'Nutzer',
52                'menuActive' => 'useraccount',
53                'workstation' => $workstation,
54                'useraccountList' => ($useraccountList) ?
55                $useraccountList->sortByCustomStringKey('id') :
56                new Collection(),
57                'ownerlist' => $ownerList,
58                'success' => $success,
59            )
60        );
61    }
62}