Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
28 / 28 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CalendarWeek | |
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\Mellon\Validator; |
| 11 | |
| 12 | class CalendarWeek extends BaseController |
| 13 | { |
| 14 | /** |
| 15 | * @SuppressWarnings(Param) |
| 16 | * @return \Psr\Http\Message\ResponseInterface |
| 17 | */ |
| 18 | #[\Override] |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ): \Psr\Http\Message\ResponseInterface { |
| 24 | // parameters |
| 25 | $selectedYear = Validator::value($args['year'])->isNumber()->getValue(); |
| 26 | $selectedWeek = Validator::value($args['weeknr'])->isString()->getValue(); |
| 27 | |
| 28 | $currentYear = \App::$now->format('Y'); |
| 29 | $currentWeek = \App::$now->format('W'); |
| 30 | |
| 31 | $selectedYear = ($selectedYear < $currentYear) ? $currentYear : $selectedYear; |
| 32 | $selectedWeek = ($selectedWeek < $currentWeek && $selectedYear <= $currentYear) ? |
| 33 | $currentWeek : |
| 34 | $selectedWeek; |
| 35 | |
| 36 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 37 | $workstationRequest = new \BO\Zmsclient\WorkstationRequests(\App::$http, $workstation); |
| 38 | $cluster = $workstationRequest->readCluster(); |
| 39 | $calendar = new Helper\Calendar(null, $selectedWeek, $selectedYear); |
| 40 | |
| 41 | $dayList = $calendar->readWeekDayListWithProcessList($cluster, $workstation); |
| 42 | |
| 43 | // rendering |
| 44 | return \BO\Slim\Render::withHtml( |
| 45 | $response, |
| 46 | 'page/calendarWeek.twig', |
| 47 | array( |
| 48 | 'title' => 'Wochenkalender', |
| 49 | 'workstation' => $workstation, |
| 50 | 'source' => $workstation->getVariantName(), |
| 51 | 'cluster' => $cluster, |
| 52 | 'calendar' => $calendar, |
| 53 | 'selectedYear' => $selectedYear, |
| 54 | 'selectedWeek' => number_format($selectedWeek), |
| 55 | 'selectedDate' => $calendar->getDateTime()->format('Y-m-d'), |
| 56 | 'dayList' => $dayList, |
| 57 | ) |
| 58 | ); |
| 59 | } |
| 60 | } |