Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
28 / 28 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
DayoffByYear | |
100.00% |
28 / 28 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
28 / 28 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | /** |
4 | * @package Zmsadmin |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsadmin; |
9 | |
10 | use BO\Zmsentities\Collection\DayoffList as Collection; |
11 | use BO\Mellon\Validator; |
12 | |
13 | class DayoffByYear 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/', ['resolveReferences' => 1])->getEntity(); |
25 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
26 | $year = Validator::value($args['year'])->isNumber()->getValue(); |
27 | $collection = \App::$http->readGetResult('/dayoff/' . $year . '/')->getCollection(); |
28 | $dayOffList = ($collection) ? array_values($collection->sortByCustomKey('date')->getArrayCopy()) : null; |
29 | |
30 | $updated = false; |
31 | $input = $request->getParsedBody(); |
32 | if (array_key_exists('save', (array) $input)) { |
33 | $data = (array_key_exists('dayoff', $input)) ? $input['dayoff'] : []; |
34 | $collection = (new Collection($data))->withTimestampFromDateformat(); |
35 | \App::$http->readPostResult('/dayoff/' . $year . '/', $collection); |
36 | $updated = true; |
37 | return \BO\Slim\Render::redirect('dayoffByYear', ['year' => $year], [ |
38 | 'success' => 'dayoff_saved' |
39 | ]); |
40 | } |
41 | |
42 | return \BO\Slim\Render::withHtml( |
43 | $response, |
44 | 'page/dayoffByYear.twig', |
45 | array( |
46 | 'title' => 'Allgemein gültige Feiertage', |
47 | 'year' => $year, |
48 | 'updated' => $updated, |
49 | 'menuActive' => 'dayoff', |
50 | 'workstation' => $workstation, |
51 | 'success' => $success, |
52 | 'dayoffList' => $dayOffList |
53 | ) |
54 | ); |
55 | } |
56 | } |