Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TicketprinterStatusByScope
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
5
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
30        $scopeId = Validator::value($args['id'])->isNumber()->getValue();
31        $scope = \App::$http->readGetResult('/scope/' . $scopeId . '/', [
32            'gql' => Helper\GraphDefaults::getScope()
33        ])->getEntity();
34
35        $input = $request->getParsedBody();
36        if (is_array($input) && array_key_exists('save', $input)) {
37            $scope->status['ticketprinter']['deactivated'] = $input['kioskausgabe'];
38            $workstation->scope['status']['ticketprinter']['deactivated'] = $input['kioskausgabe'];
39            if ($input['hinweis']) {
40                if (! isset($scope->preferences['ticketprinter'])) {
41                    $scope->preferences['ticketprinter'] = [];
42                }
43            }
44            $scope->preferences['ticketprinter']['deactivatedText'] = $input['hinweis'];
45            $scope = \App::$http->readPostResult('/scope/' . $scope->id . '/', $scope)->getEntity();
46
47            return \BO\Slim\Render::redirect('ticketprinterStatusByScope', ['id' => $scopeId], [
48                'success' => 'ticketprinter_deactivated_' . $scope->status['ticketprinter']['deactivated']
49            ]);
50        }
51
52        return \BO\Slim\Render::withHtml(
53            $response,
54            'page/ticketprinterStatus.twig',
55            array(
56                'title' => 'Wartenummernausgabe am Kiosk',
57                'menuActive' => 'ticketprinterStatus',
58                'workstation' => $workstation,
59                'scope' => $scope->getArrayCopy(),
60                'success' => $success
61            )
62        );
63    }
64}