Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| WorkstationDelete | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ZMS API |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsapi; |
| 9 | |
| 10 | use BO\Slim\Render; |
| 11 | use BO\Mellon\Validator; |
| 12 | use BO\Zmsdb\Log; |
| 13 | use BO\Zmsdb\Workstation; |
| 14 | use BO\Zmsdb\Useraccount; |
| 15 | |
| 16 | class WorkstationDelete 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 | \BO\Zmsdb\Connection\Select::getWriteConnection(); |
| 28 | $workstation = (new Helper\User($request, 1))->checkRights(); |
| 29 | $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(2)->getValue(); |
| 30 | if (! (new Useraccount())->readIsUserExisting($args['loginname'])) { |
| 31 | throw new Exception\Useraccount\UseraccountNotFound(); |
| 32 | } |
| 33 | if ($workstation->process && $workstation->process->hasId()) { |
| 34 | throw new Exception\Workstation\WorkstationHasCalledProcess(); |
| 35 | } |
| 36 | |
| 37 | $message = Response\Message::create($request); |
| 38 | $message->data = (new Workstation())->writeEntityLogoutByName($args['loginname'], $resolveReferences); |
| 39 | |
| 40 | $response = Render::withLastModified($response, time(), '0'); |
| 41 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
| 42 | |
| 43 | \BO\Zmsdb\Log::writeLogEntry( |
| 44 | "LOGOUT (WorkstattionDelete::readResponse) " . $args['loginname'], |
| 45 | 0, |
| 46 | Log::PROCESS, |
| 47 | $workstation->getScope()->getId(), |
| 48 | $workstation->getUseraccount()->getId() |
| 49 | ); |
| 50 | |
| 51 | return $response; |
| 52 | } |
| 53 | } |