mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-25 00:53:48 +00:00
Create AccompanyingCourseDocumentRepository and use to add pagination
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||
use Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType;
|
||||
use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
@@ -38,6 +39,8 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private AccompanyingCourseDocumentRepository $courseRepository;
|
||||
|
||||
/**
|
||||
* DocumentAccompanyingCourseController constructor.
|
||||
*/
|
||||
@@ -45,12 +48,14 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
TranslatorInterface $translator,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
AccompanyingCourseDocumentRepository $courseRepository
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->courseRepository = $courseRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,15 +131,17 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::SEE, $course);
|
||||
|
||||
$documents = $em
|
||||
->getRepository('ChillDocStoreBundle:AccompanyingCourseDocument')
|
||||
$total = $this->courseRepository->countByCourse($course);
|
||||
$pagination = $this->paginatorFactory->create($total);
|
||||
|
||||
$documents = $this->courseRepository
|
||||
->findBy(
|
||||
['course' => $course],
|
||||
['date' => 'DESC']
|
||||
['date' => 'DESC'],
|
||||
$pagination->getItemsPerPage(),
|
||||
$pagination->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
$total = count($documents);
|
||||
$pagination = $this->paginatorFactory->create($total);
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig',
|
||||
|
Reference in New Issue
Block a user