From ad4d1caa9e744af57ca58a4e57576533eb682d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 23 Jan 2015 16:28:37 +0100 Subject: move WallabagBundle into Wallabag:CoreBundle --- .../CoreBundle/Repository/EntriesRepository.php | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Repository/EntriesRepository.php (limited to 'src/Wallabag/CoreBundle/Repository') diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php new file mode 100644 index 00000000..5a71b9ef --- /dev/null +++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php @@ -0,0 +1,79 @@ +createQueryBuilder('e') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isRead = 0') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($qb); + + 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') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isRead = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($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') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isFav = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($qb); + + return $paginator; + } +} -- cgit v1.2.3