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