From e0c7daf3fde348b7ee2aa23cc8a15958e4951310 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Feb 2022 15:10:04 +0100 Subject: [PATCH] Pagination added --- .env | 64 ------------------- .../DocumentAccompanyingCourseController.php | 26 ++++---- .../Controller/DocumentPersonController.php | 26 ++++---- .../index.html.twig | 2 + .../views/PersonDocument/index.html.twig | 2 + 5 files changed, 30 insertions(+), 90 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 619f471ca..000000000 --- a/.env +++ /dev/null @@ -1,64 +0,0 @@ -## -## Manually dump .env files in .env.local.php with -## `$ composer symfony:dump-env prod` -## - -## Project environment -APP_ENV=dev - -## Enable debug -APP_DEBUG=true - -## Locale -LOCALE=fr - -## Framework secret -APP_SECRET=ThisTokenIsNotSoSecretChangeIt - -## Symfony/swiftmailer -MAILER_TRANSPORT=smtp -MAILER_HOST=smtp -MAILER_PORT=1025 -MAILER_CRYPT= -MAILER_AUTH= -MAILER_USER= -MAILER_PASSWORD= -MAILER_URL=${MAILER_TRANSPORT}://${MAILER_HOST}:${MAILER_PORT}?encryption=${MAILER_CRYPT}&auth_mode=${MAILER_AUTH}&username=${MAILER_USER}&password=${MAILER_PASSWORD} - -## Notifications -NOTIFICATION_HOST=localhost:8001 -NOTIFICATION_FROM_EMAIL=admin@chill.social -NOTIFICATION_FROM_NAME=Chill - -## Gelf -GELF_HOST=gelf -GELF_PORT=12201 - -## OVH OpenStack Storage User/Role -OS_USERNAME= -OS_PASSWORD= -OS_TENANT_ID= -OS_REGION_NAME=GRA -OS_AUTH_URL=https://auth.cloud.ovh.net/v2.0/ - -## OVH OpenStack Storage Container -ASYNC_UPLOAD_TEMP_URL_KEY= -ASYNC_UPLOAD_TEMP_URL_BASE_PATH= -ASYNC_UPLOAD_TEMP_URL_CONTAINER= - -## Redis Cache -REDIS_HOST=redis -REDIS_PORT=6379 -REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} - -## Twilio -TWILIO_SID=~ -TWILIO_SECRET=~ - -## DOCKER IMAGES REGISTRY -#IMAGE_PHP= -#IMAGE_NGINX= - -## DOCKER IMAGES VERSION -#VERSION=test -VERSION=prod diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index a5ad5cfa1..253fa49b3 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType; use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter; +use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\AccompanyingPeriod; use DateTime; @@ -29,20 +30,13 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class DocumentAccompanyingCourseController extends AbstractController { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; + protected AuthorizationHelper $authorizationHelper; - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; + protected EventDispatcherInterface $eventDispatcher; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; + + private PaginatorFactory $paginatorFactory; /** * DocumentAccompanyingCourseController constructor. @@ -50,11 +44,13 @@ class DocumentAccompanyingCourseController extends AbstractController public function __construct( TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper + AuthorizationHelper $authorizationHelper, + PaginatorFactory $paginatorFactory ) { $this->translator = $translator; $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; + $this->paginatorFactory = $paginatorFactory; } /** @@ -137,11 +133,15 @@ class DocumentAccompanyingCourseController extends AbstractController ['date' => 'DESC'] ); + $total = count($documents); + $pagination = $this->paginatorFactory->create($total); + return $this->render( 'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig', [ 'documents' => $documents, 'accompanyingCourse' => $course, + 'pagination' => $pagination ] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 5028757bd..994a5d70f 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Form\PersonDocumentType; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; +use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; @@ -35,20 +36,13 @@ use Symfony\Component\Translation\TranslatorInterface; */ class DocumentPersonController extends AbstractController { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; + protected AuthorizationHelper $authorizationHelper; - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; + protected EventDispatcherInterface $eventDispatcher; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; + + private PaginatorFactory $paginatorFactory; /** * DocumentPersonController constructor. @@ -56,11 +50,13 @@ class DocumentPersonController extends AbstractController public function __construct( TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper + AuthorizationHelper $authorizationHelper, + PaginatorFactory $paginatorFactory ) { $this->translator = $translator; $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; + $this->paginatorFactory = $paginatorFactory; } /** @@ -170,6 +166,9 @@ class DocumentPersonController extends AbstractController ['date' => 'DESC'] ); + $total = count($documents); + $pagination = $this->paginatorFactory->create($total); + $event = new PrivacyEvent($person, [ 'element_class' => PersonDocument::class, 'action' => 'index', @@ -181,6 +180,7 @@ class DocumentPersonController extends AbstractController [ 'documents' => $documents, 'person' => $person, + 'pagination' => $pagination ] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index a0c60d9b3..7c9a574d0 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -32,6 +32,8 @@ {% endif %} + {{ chill_pagination(pagination) }} +
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig index 95950fc89..bb0d92972 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig @@ -44,6 +44,8 @@ {% endif %} + {{ chill_pagination(pagination) }} + {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %}