From b84a80559a1167b5500fbc5eb4965d3b08b371ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 23 Jan 2015 14:58:17 +0100 Subject: some parameters, new entry form, etc. --- .../Repository/EntriesRepository.php | 42 +++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'src/WallabagBundle/Repository') diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index c4428a1d..3eb1733d 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php @@ -8,6 +8,14 @@ use Doctrine\ORM\Tools\Pagination\Paginator; class EntriesRepository extends EntityRepository { + /** + * Retrieves unread entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findUnreadByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository ->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->getQuery(); - $pag = new Paginator($qb); + $paginator = new Paginator($qb); - return $pag; + return $paginator; } + /** + * Retrieves read entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findArchiveByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isRead = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); + + $paginator = new Paginator($qb); - return $qb; + return $paginator; } + /** + * Retrieves starred entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findStarredByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isFav = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); + + $paginator = new Paginator($qb); - return $qb; + return $paginator; } } -- cgit v1.2.3