Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
97.06% covered (success)
97.06%
33 / 34
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TicketprinterStatusByScope
97.06% covered (success)
97.06%
33 / 34
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 readResponse
97.06% covered (success)
97.06%
33 / 34
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\Zmsentities\Scope as Entity;
11use BO\Mellon\Validator;
12
13class TicketprinterStatusByScope extends BaseController
14{
15    /**
16     *
17     * @return String
18     */
19    public function readResponse(
20        \Psr\Http\Message\RequestInterface $request,
21        \Psr\Http\Message\ResponseInterface $response,
22        array $args
23    ) {
24        $workstation = \App::$http->readGetResult('/workstation/', [
25            'resolveReferences' => 1,
26            'gql' => Helper\GraphDefaults::getWorkstation()
27        ])->getEntity();
28        $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue();
29        if (!$workstation->getUseraccount()->hasPermissions(['ticketprinter', 'scope'])) {
30            throw new \BO\Zmsentities\Exception\UserAccountMissingRights();
31        }
32        $scopeId = Validator::value($args['id'])->isNumber()->getValue();
33        $scope = \App::$http->readGetResult('/scope/' . $scopeId . '/', [
34            'gql' => Helper\GraphDefaults::getScope()
35        ])->getEntity();
36
37        $input = $request->getParsedBody();
38        if (is_array($input) && array_key_exists('save', $input)) {
39            $scope->status['ticketprinter']['deactivated'] = $input['kioskausgabe'];
40            $workstation->scope['status']['ticketprinter']['deactivated'] = $input['kioskausgabe'];
41            if ($input['hinweis']) {
42                if (! isset($scope->preferences['ticketprinter'])) {
43                    $scope->preferences['ticketprinter'] = [];
44                }
45            }
46            $scope->preferences['ticketprinter']['deactivatedText'] = $input['hinweis'];
47            $scope = \App::$http->readPostResult('/scope/' . $scope->id . '/', $scope)->getEntity();
48
49            return \BO\Slim\Render::redirect('ticketprinterStatusByScope', ['id' => $scopeId], [
50                'success' => 'ticketprinter_deactivated_' . $scope->status['ticketprinter']['deactivated']
51            ]);
52        }
53
54        return \BO\Slim\Render::withHtml(
55            $response,
56            'page/ticketprinterStatus.twig',
57            array(
58                'title' => 'Wartenummernausgabe am Kiosk',
59                'menuActive' => 'ticketprinterStatus',
60                'workstation' => $workstation,
61                'scope' => $scope->getArrayCopy(),
62                'success' => $success
63            )
64        );
65    }
66}