security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) { throw new AccessDeniedHttpException("not allowed to see the documents for accompanying period"); } $filterBuilder = $this->filterOrderHelperFactory ->create(self::class) ->addSearchBox() ->addDateRange('dateRange', 'generic_doc.filter.date-range'); if ([] !== $places = $this->manager->placesForAccompanyingPeriod($accompanyingPeriod)) { $filterBuilder->addCheckbox('places', $places, [], array_map( static fn (string $k) => 'generic_doc.filter.keys.' . $k, $places )); } $filter = $filterBuilder ->build(); ['to' => $endDate, 'from' => $startDate ] = $filter->getDateRangeData('dateRange'); $content = $filter->getQueryString(); $nb = $this->manager->countDocForAccompanyingPeriod( $accompanyingPeriod, $startDate, $endDate, $content, $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] ); $paginator = $this->paginator->create($nb); $documents = $this->manager->findDocForAccompanyingPeriod( $accompanyingPeriod, $paginator->getCurrentPageFirstItemNumber(), $paginator->getItemsPerPage(), $startDate, $endDate, $content, $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] ); return new Response($this->twig->render( '@ChillDocStore/GenericDoc/accompanying_period_list.html.twig', [ 'accompanyingCourse' => $accompanyingPeriod, 'pagination' => $paginator, 'documents' => iterator_to_array($documents), 'filter' => $filter, ] )); } }