Skip to content

Commit

Permalink
Fix sort/filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Acrack committed Jun 24, 2014
1 parent 53d970e commit c2b6d52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
10 changes: 8 additions & 2 deletions Controller/CrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
Expand All @@ -358,7 +364,7 @@ private function getQuery()
*/
protected function doIndex()
{
$result = $this->getQuery()->getResult();
$result = $this->getQuery();

return $this->renderIndex($result);
}
Expand Down

0 comments on commit c2b6d52

Please sign in to comment.