From 9fb6ac830fa669beef1dd11070421262c073192c Mon Sep 17 00:00:00 2001 From: Francois Gravelaine Date: Mon, 27 Jul 2015 23:20:32 +0200 Subject: Adds pagerfanta paginator everywhere, modifies article routing. Change API for is_starred and is_archived --- .../CoreBundle/Repository/EntryRepository.php | 38 ++++++++-------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 1335e808..a4514d9e 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -3,7 +3,6 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\Tools\Pagination\Paginator; use Pagerfanta\Adapter\DoctrineORMAdapter; use Pagerfanta\Pagerfanta; @@ -13,77 +12,66 @@ class EntryRepository extends EntityRepository * Retrieves unread entries for a user. * * @param int $userId - * @param int $firstResult - * @param int $maxResults * - * @return Paginator + * @return Pagerfanta */ - public function findUnreadByUser($userId, $firstResult, $maxResults = 12) + public function findUnreadByUser($userId) { $qb = $this->createQueryBuilder('e') - ->setFirstResult($firstResult) - ->setMaxResults($maxResults) ->leftJoin('e.user', 'u') ->where('e.isArchived = false') ->andWhere('u.id =:userId')->setParameter('userId', $userId) ->orderBy('e.id', 'desc') ->getQuery(); - $paginator = new Paginator($qb); + $pagerAdapter = new DoctrineORMAdapter($qb); - return $paginator; + return new Pagerfanta($pagerAdapter); } /** * Retrieves read entries for a user. * * @param int $userId - * @param int $firstResult - * @param int $maxResults * - * @return Paginator + * @return Pagerfanta */ - public function findArchiveByUser($userId, $firstResult, $maxResults = 12) + public function findArchiveByUser($userId) { $qb = $this->createQueryBuilder('e') ->select('e') - ->setFirstResult($firstResult) - ->setMaxResults($maxResults) ->leftJoin('e.user', 'u') ->where('e.isArchived = true') ->andWhere('u.id =:userId')->setParameter('userId', $userId) ->orderBy('e.id', 'desc') ->getQuery(); - $paginator = new Paginator($qb); + $pagerAdapter = new DoctrineORMAdapter($qb); - return $paginator; + return new Pagerfanta($pagerAdapter); } /** * Retrieves starred entries for a user. * * @param int $userId - * @param int $firstResult - * @param int $maxResults * - * @return Paginator + * @return Pagerfanta */ - public function findStarredByUser($userId, $firstResult, $maxResults = 12) + public function findStarredByUser($userId) { + $qb = $this->createQueryBuilder('e') ->select('e') - ->setFirstResult($firstResult) - ->setMaxResults($maxResults) ->leftJoin('e.user', 'u') ->where('e.isStarred = true') ->andWhere('u.id =:userId')->setParameter('userId', $userId) ->orderBy('e.id', 'desc') ->getQuery(); - $paginator = new Paginator($qb); + $pagerAdapter = new DoctrineORMAdapter($qb); - return $paginator; + return new Pagerfanta($pagerAdapter); } /** -- cgit v1.2.3