diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-23 14:58:17 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-23 14:58:17 +0100 |
commit | b84a80559a1167b5500fbc5eb4965d3b08b371ef (patch) | |
tree | f7d0e9917f650b6317b986c9e8baf38880a4fb2e /src/WallabagBundle/Repository | |
parent | 163eae0bb15d0daa5390f434a42a8176eca186e7 (diff) | |
download | wallabag-b84a80559a1167b5500fbc5eb4965d3b08b371ef.tar.gz wallabag-b84a80559a1167b5500fbc5eb4965d3b08b371ef.tar.zst wallabag-b84a80559a1167b5500fbc5eb4965d3b08b371ef.zip |
some parameters, new entry form, etc.
Diffstat (limited to 'src/WallabagBundle/Repository')
-rw-r--r-- | src/WallabagBundle/Repository/EntriesRepository.php | 42 |
1 files changed, 34 insertions, 8 deletions
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; | |||
8 | 8 | ||
9 | class EntriesRepository extends EntityRepository | 9 | class EntriesRepository extends EntityRepository |
10 | { | 10 | { |
11 | /** | ||
12 | * Retrieves unread entries for a user | ||
13 | * | ||
14 | * @param $userId | ||
15 | * @param $firstResult | ||
16 | * @param int $maxResults | ||
17 | * @return Paginator | ||
18 | */ | ||
11 | public function findUnreadByUser($userId, $firstResult, $maxResults = 12) | 19 | public function findUnreadByUser($userId, $firstResult, $maxResults = 12) |
12 | { | 20 | { |
13 | $qb = $this->createQueryBuilder('e') | 21 | $qb = $this->createQueryBuilder('e') |
@@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository | |||
18 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 26 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
19 | ->getQuery(); | 27 | ->getQuery(); |
20 | 28 | ||
21 | $pag = new Paginator($qb); | 29 | $paginator = new Paginator($qb); |
22 | 30 | ||
23 | return $pag; | 31 | return $paginator; |
24 | } | 32 | } |
25 | 33 | ||
34 | /** | ||
35 | * Retrieves read entries for a user | ||
36 | * | ||
37 | * @param $userId | ||
38 | * @param $firstResult | ||
39 | * @param int $maxResults | ||
40 | * @return Paginator | ||
41 | */ | ||
26 | public function findArchiveByUser($userId, $firstResult, $maxResults = 12) | 42 | public function findArchiveByUser($userId, $firstResult, $maxResults = 12) |
27 | { | 43 | { |
28 | $qb = $this->createQueryBuilder('e') | 44 | $qb = $this->createQueryBuilder('e') |
@@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository | |||
31 | ->setMaxResults($maxResults) | 47 | ->setMaxResults($maxResults) |
32 | ->where('e.isRead = 1') | 48 | ->where('e.isRead = 1') |
33 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 49 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
34 | ->getQuery() | 50 | ->getQuery(); |
35 | ->getResult(Query::HYDRATE_ARRAY); | 51 | |
52 | $paginator = new Paginator($qb); | ||
36 | 53 | ||
37 | return $qb; | 54 | return $paginator; |
38 | } | 55 | } |
39 | 56 | ||
57 | /** | ||
58 | * Retrieves starred entries for a user | ||
59 | * | ||
60 | * @param $userId | ||
61 | * @param $firstResult | ||
62 | * @param int $maxResults | ||
63 | * @return Paginator | ||
64 | */ | ||
40 | public function findStarredByUser($userId, $firstResult, $maxResults = 12) | 65 | public function findStarredByUser($userId, $firstResult, $maxResults = 12) |
41 | { | 66 | { |
42 | $qb = $this->createQueryBuilder('e') | 67 | $qb = $this->createQueryBuilder('e') |
@@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository | |||
45 | ->setMaxResults($maxResults) | 70 | ->setMaxResults($maxResults) |
46 | ->where('e.isFav = 1') | 71 | ->where('e.isFav = 1') |
47 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 72 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
48 | ->getQuery() | 73 | ->getQuery(); |
49 | ->getResult(Query::HYDRATE_ARRAY); | 74 | |
75 | $paginator = new Paginator($qb); | ||
50 | 76 | ||
51 | return $qb; | 77 | return $paginator; |
52 | } | 78 | } |
53 | } | 79 | } |