From c2b6d522ff047f31050be0454bdb620f592c701e Mon Sep 17 00:00:00 2001 From: Acrack Date: Tue, 24 Jun 2014 10:36:52 +0200 Subject: [PATCH] Fix sort/filter --- Controller/BaseController.php | 3 ++- Controller/CrudController.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Controller/BaseController.php b/Controller/BaseController.php index d0dfe4c..4decc2f 100644 --- a/Controller/BaseController.php +++ b/Controller/BaseController.php @@ -90,7 +90,8 @@ protected function getPagination($query, $elementsPerPage) return $this->get('knp_paginator')->paginate( $query, $this->getRequest()->query->get('page', 1), - $elementsPerPage + $elementsPerPage, + array('distinct' => false) ); } diff --git a/Controller/CrudController.php b/Controller/CrudController.php index 2cfe613..5e55386 100644 --- a/Controller/CrudController.php +++ b/Controller/CrudController.php @@ -325,6 +325,11 @@ protected function getGlobalActions() */ private function getQuery() { + $count = $this + ->getEntityManager() + ->createQuery('SELECT COUNT(e) FROM ' . $this->getEntityClass() . ' e') + ->getSingleScalarResult(); + $entityClass = ltrim($this->getEntityClass(), '\\'); $entityName = $this->getEntityName(); @@ -346,7 +351,8 @@ private function getQuery() ->setHint( Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\Translatable\Query\TreeWalker\TranslationWalker' - ); + ) + ->setHint('knp_paginator.count', $count); return $query; } @@ -358,7 +364,7 @@ private function getQuery() */ protected function doIndex() { - $result = $this->getQuery()->getResult(); + $result = $this->getQuery(); return $this->renderIndex($result); }