]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Repository/EntriesRepository.php
fix config for rest bundle
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntriesRepository.php
CommitLineData
9d50517c
NL
1<?php
2
ad4d1caa 3namespace Wallabag\CoreBundle\Repository;
9d50517c
NL
4
5use Doctrine\ORM\Query;
6use Doctrine\ORM\EntityRepository;
163eae0b 7use Doctrine\ORM\Tools\Pagination\Paginator;
9d50517c 8
9d50517c
NL
9class EntriesRepository extends EntityRepository
10{
b84a8055
NL
11 /**
12 * Retrieves unread entries for a user
13 *
14 * @param $userId
15 * @param $firstResult
16 * @param int $maxResults
17 * @return Paginator
18 */
163eae0b 19 public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
9d50517c
NL
20 {
21 $qb = $this->createQueryBuilder('e')
22 ->select('e')
163eae0b
NL
23 ->setFirstResult($firstResult)
24 ->setMaxResults($maxResults)
9d50517c
NL
25 ->where('e.isRead = 0')
26 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
163eae0b 27 ->getQuery();
9d50517c 28
b84a8055 29 $paginator = new Paginator($qb);
163eae0b 30
b84a8055 31 return $paginator;
9d50517c 32 }
bd9f0815 33
b84a8055
NL
34 /**
35 * Retrieves read entries for a user
36 *
37 * @param $userId
38 * @param $firstResult
39 * @param int $maxResults
40 * @return Paginator
41 */
163eae0b 42 public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
bd9f0815
NL
43 {
44 $qb = $this->createQueryBuilder('e')
45 ->select('e')
163eae0b
NL
46 ->setFirstResult($firstResult)
47 ->setMaxResults($maxResults)
bd9f0815
NL
48 ->where('e.isRead = 1')
49 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
b84a8055
NL
50 ->getQuery();
51
52 $paginator = new Paginator($qb);
bd9f0815 53
b84a8055 54 return $paginator;
bd9f0815
NL
55 }
56
b84a8055
NL
57 /**
58 * Retrieves starred entries for a user
59 *
60 * @param $userId
61 * @param $firstResult
62 * @param int $maxResults
63 * @return Paginator
64 */
163eae0b 65 public function findStarredByUser($userId, $firstResult, $maxResults = 12)
bd9f0815
NL
66 {
67 $qb = $this->createQueryBuilder('e')
68 ->select('e')
163eae0b
NL
69 ->setFirstResult($firstResult)
70 ->setMaxResults($maxResults)
bd9f0815
NL
71 ->where('e.isFav = 1')
72 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
b84a8055
NL
73 ->getQuery();
74
75 $paginator = new Paginator($qb);
bd9f0815 76
b84a8055 77 return $paginator;
bd9f0815 78 }
9d50517c 79}