Skip to content

Commit

Permalink
Merge pull request #51 from mtarld/fix/doctrine-count
Browse files Browse the repository at this point in the history
fix: rely on doctrine paginator for counting
  • Loading branch information
mtarld authored Dec 27, 2023
2 parents 87fbbf6 + e67b03d commit 97fee96
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Shared/Infrastructure/Doctrine/DoctrineRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,9 @@ public function getIterator(): \Iterator

public function count(): int
{
if (null !== $paginator = $this->paginator()) {
return count($paginator);
}
$paginator = $this->paginator() ?? new Paginator(clone $this->queryBuilder);

return (int) (clone $this->queryBuilder)
->select('count(1)')
->getQuery()
->getSingleScalarResult();
return count($paginator);
}

public function paginator(): ?PaginatorInterface
Expand Down

0 comments on commit 97fee96

Please sign in to comment.