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\Zmsentities\Scope; |
| 11 | use BO\Mellon\Validator; |
| 12 | |
| 13 | class CalendarWeek extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @SuppressWarnings(Param) |
| 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 | // 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 | // HTTP requests |
| 37 | /** @var \BO\Zmsentities\Workstation $workstation */ |
| 38 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 39 | $workstationRequest = new \BO\Zmsclient\WorkstationRequests(\App::$http, $workstation); |
| 40 | $cluster = $workstationRequest->readCluster(); |
| 41 | $calendar = new Helper\Calendar(null, $selectedWeek, $selectedYear); |
| 42 | |
| 43 | $dayList = $calendar->readWeekDayListWithProcessList($cluster, $workstation); |
| 44 | |
| 45 | // rendering |
| 46 | return \BO\Slim\Render::withHtml( |
| 47 | $response, |
| 48 | 'page/calendarWeek.twig', |
| 49 | array( |
| 50 | 'title' => 'Wochenkalender', |
| 51 | 'workstation' => $workstation, |
| 52 | 'source' => $workstation->getVariantName(), |
| 53 | 'cluster' => $cluster, |
| 54 | 'calendar' => $calendar, |
| 55 | 'selectedYear' => $selectedYear, |
| 56 | 'selectedWeek' => number_format($selectedWeek), |
| 57 | 'selectedDate' => $calendar->getDateTime()->format('Y-m-d'), |
| 58 | 'dayList' => $dayList, |
| 59 | ) |
| 60 | ); |
| 61 | } |
| 62 | } |