From 8ab9135e50feb77fe63bfc4cd93950379e9363f1 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Wed, 22 Nov 2023 09:32:27 +0000 Subject: [PATCH] view all publications --- .../Controller/Admin/Edition/HtmlController.php | 2 +- .../Controller/Admin/Edition/PdfController.php | 2 +- .../PublicationBundle/Repository/Edition/Html.php | 15 +++++++++++++++ .../PublicationBundle/Repository/Edition/Pdf.php | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/module/PublicationBundle/Controller/Admin/Edition/HtmlController.php b/module/PublicationBundle/Controller/Admin/Edition/HtmlController.php index 089393e07d..f56edaea04 100644 --- a/module/PublicationBundle/Controller/Admin/Edition/HtmlController.php +++ b/module/PublicationBundle/Controller/Admin/Edition/HtmlController.php @@ -25,7 +25,7 @@ public function manageAction() $paginator = $this->paginator()->createFromQuery( $this->getEntityManager() ->getRepository('PublicationBundle\Entity\Edition\Html') - ->findAllByPublicationAndAcademicYearQuery($publication, $this->getCurrentAcademicYear()), + ->findAllByPublicationQuery($publication, $this->getCurrentAcademicYear()), $this->getParam('page') ); diff --git a/module/PublicationBundle/Controller/Admin/Edition/PdfController.php b/module/PublicationBundle/Controller/Admin/Edition/PdfController.php index de4d0e5097..ccda1c2f1a 100644 --- a/module/PublicationBundle/Controller/Admin/Edition/PdfController.php +++ b/module/PublicationBundle/Controller/Admin/Edition/PdfController.php @@ -25,7 +25,7 @@ public function manageAction() $paginator = $this->paginator()->createFromQuery( $this->getEntityManager() ->getRepository('PublicationBundle\Entity\Edition\Pdf') - ->findAllByPublicationAndAcademicYearQuery($publication, $this->getCurrentAcademicYear()), + ->findAllByPublicationQuery($publication, $this->getCurrentAcademicYear()), $this->getParam('page') ); diff --git a/module/PublicationBundle/Repository/Edition/Html.php b/module/PublicationBundle/Repository/Edition/Html.php index 8432c8806e..0fdefd308f 100644 --- a/module/PublicationBundle/Repository/Edition/Html.php +++ b/module/PublicationBundle/Repository/Edition/Html.php @@ -30,6 +30,21 @@ public function findAllByPublicationAndAcademicYearQuery(PublicationEntity $publ ->getQuery(); } + public function findAllByPublicationQuery(PublicationEntity $publication) + { + $query = $this->getEntityManager()->createQueryBuilder(); + return $query->select('p') + ->from('PublicationBundle\Entity\Edition\Html', 'p') + ->where( + $query->expr()->andX( + $query->expr()->eq('p.publication', ':publication'), + ) + ) + ->setParameter('publication', $publication) + ->orderBy('p.date', 'DESC') + ->getQuery(); + } + public function findOneByPublicationTitleAndAcademicYear(PublicationEntity $publication, $title, AcademicYear $academicYear) { $query = $this->getEntityManager()->createQueryBuilder(); diff --git a/module/PublicationBundle/Repository/Edition/Pdf.php b/module/PublicationBundle/Repository/Edition/Pdf.php index 2e8e73ced7..29f66d59bc 100644 --- a/module/PublicationBundle/Repository/Edition/Pdf.php +++ b/module/PublicationBundle/Repository/Edition/Pdf.php @@ -30,6 +30,21 @@ public function findAllByPublicationAndAcademicYearQuery(PublicationEntity $publ ->getQuery(); } + public function findAllByPublicationQuery(PublicationEntity $publication) + { + $query = $this->getEntityManager()->createQueryBuilder(); + return $query->select('p') + ->from('PublicationBundle\Entity\Edition\Pdf', 'p') + ->where( + $query->expr()->andX( + $query->expr()->eq('p.publication', ':publication'), + ) + ) + ->setParameter('publication', $publication) + ->orderBy('p.date', 'DESC') + ->getQuery(); + } + public function findOneByPublicationTitleAndAcademicYear(PublicationEntity $publication, $title, AcademicYear $academicYear) { $query = $this->getEntityManager()->createQueryBuilder();