Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
38 / 38
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PickupQueue
100.00% covered (success)
100.00%
38 / 38
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
1 / 1
3
 getProcessList
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10class PickupQueue extends BaseController
11{
12    /**
13     * @SuppressWarnings(Param)
14     * @return String
15     */
16    public function readResponse(
17        \Psr\Http\Message\RequestInterface $request,
18        \Psr\Http\Message\ResponseInterface $response,
19        array $args
20    ) {
21        $validator = $request->getAttribute('validator');
22        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
23        $selectedScope = $validator->getParameter('selectedscope')->isNumber()->getValue();
24        $limit = $validator->getParameter('limit')->isNumber()->setDefault(Pickup::$defaultLimit)->getValue();
25        $offset = $validator->getParameter('offset')->isNumber()->setDefault(0)->getValue();
26        $scopeId = ($selectedScope) ? $selectedScope : $workstation->scope['id'];
27        $scope = \App::$http->readGetResult('/scope/' . $scopeId . '/')->getEntity();
28        $department = \App::$http->readGetResult(
29            '/scope/' . $workstation->scope['id'] . '/department/',
30            [
31                'resolveReferences' => 2
32            ]
33        )->getEntity();
34
35        $validator = $request->getAttribute('validator');
36        $handheld = $validator->getParameter('handheld')->isNumber()->setDefault(0)->getValue();
37        $template = ($handheld) ? 'table-handheld' : 'table';
38
39        return \BO\Slim\Render::withHtml(
40            $response,
41            'block/pickup/' . $template . '.twig',
42            array(
43              'workstation' => $workstation,
44              'pickupList' => $department->getScopeList(),
45              'department' => $department,
46              'scope' => $scope,
47              'limit' => $limit,
48              'offset' => $offset,
49              'processList' => static::getProcessList($scopeId, $limit, $offset),
50              'processListNext' => static::getProcessList($scopeId, $limit, $offset + $limit),
51            )
52        );
53    }
54
55    public static function getProcessList($scopeId, $limit = 500, $offset = 0)
56    {
57        $processList = \App::$http->readGetResult('/workstation/process/pickup/', [
58            'resolveReferences' => 1,
59            'selectedScope' => $scopeId,
60            'limit' => $limit,
61            'offset' => $offset,
62            'gql' => Helper\GraphDefaults::getPickup()
63        ])->getCollection();
64        return ($processList) ? $processList->sortPickupQueue() : $processList;
65    }
66}