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
LogoutBySuperuser 100.00% 13 / 13 100.00% 1 / 1 4 100.00% 1 / 1
 readResponse 100.00% 13 / 13 100.00% 1 / 1 4
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsclient\Auth;
11use BO\Mellon\Validator;
12
13class LogoutBySuperuser extends BaseController
14{
15    /**
16     * @SuppressWarnings(Param)
17     * @return \Psr\Http\Message\ResponseInterface
18     */
19    #[\Override]
20    public function readResponse(
21        \Psr\Http\Message\RequestInterface $request,
22        \Psr\Http\Message\ResponseInterface $response,
23        array $args
24    ): \Psr\Http\Message\ResponseInterface {
25        $validator = $request->getAttribute('validator');
26        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 0])->getEntity();
27        $workstationToLogout = $validator->getParameter('workstation')->isArray()->getValue();
28
29        if (
30            array_key_exists('useraccount', $workstationToLogout) &&
31            isset($workstationToLogout['useraccount']['id']) &&
32            $workstation->hasSuperUseraccount()
33        ) {
34                \App::$http->readDeleteResult('/workstation/login/' . $workstationToLogout['useraccount']['id'] . '/');
35        }
36
37        $departmentId = Validator::value($args['id'])->isNumber()->getValue();
38        return \BO\Slim\Render::redirect(
39            'useraccountListByDepartment',
40            array('id' => $departmentId),
41            array()
42        );
43    }
44}