1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-10-20 19:52:09 +00:00

Adds pagerfanta paginator everywhere, modifies article routing. Change API for is_starred and is_archived

This commit is contained in:
Francois Gravelaine 2015-07-27 23:20:32 +02:00
parent 9b9b05008a
commit 9fb6ac830f
8 changed files with 76 additions and 59 deletions

View file

@ -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);
}
/**