diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-06 07:45:32 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-06 07:45:32 +0100 |
commit | be463487cc195026b11e92f1d6d6276f5851b97e (patch) | |
tree | 5d5bd15db7ae19994da55574ade821acdc115c36 /src/Wallabag/CoreBundle/Repository/EntriesRepository.php | |
parent | 905ae369bd0238cc24c3c4e0ac60d578d30b54bb (diff) | |
download | wallabag-be463487cc195026b11e92f1d6d6276f5851b97e.tar.gz wallabag-be463487cc195026b11e92f1d6d6276f5851b97e.tar.zst wallabag-be463487cc195026b11e92f1d6d6276f5851b97e.zip |
rename Entries to Entry
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntriesRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntriesRepository.php | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php deleted file mode 100644 index 9965317a..00000000 --- a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
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 | use Wallabag\CoreBundle\Entity\Entries; | ||
9 | |||
10 | class EntriesRepository extends EntityRepository | ||
11 | { | ||
12 | /** | ||
13 | * Retrieves unread entries for a user | ||
14 | * | ||
15 | * @param $userId | ||
16 | * @param $firstResult | ||
17 | * @param int $maxResults | ||
18 | * @return Paginator | ||
19 | */ | ||
20 | public function findUnreadByUser($userId, $firstResult, $maxResults = 12) | ||
21 | { | ||
22 | $qb = $this->createQueryBuilder('e') | ||
23 | ->select('e') | ||
24 | ->setFirstResult($firstResult) | ||
25 | ->setMaxResults($maxResults) | ||
26 | ->where('e.isArchived = false') | ||
27 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | ||
28 | ->andWhere('e.isDeleted=false') | ||
29 | ->orderBy('e.createdAt', 'desc') | ||
30 | ->getQuery(); | ||
31 | |||
32 | $paginator = new Paginator($qb); | ||
33 | |||
34 | return $paginator; | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * Retrieves read entries for a user | ||
39 | * | ||
40 | * @param $userId | ||
41 | * @param $firstResult | ||
42 | * @param int $maxResults | ||
43 | * @return Paginator | ||
44 | */ | ||
45 | public function findArchiveByUser($userId, $firstResult, $maxResults = 12) | ||
46 | { | ||
47 | $qb = $this->createQueryBuilder('e') | ||
48 | ->select('e') | ||
49 | ->setFirstResult($firstResult) | ||
50 | ->setMaxResults($maxResults) | ||
51 | ->where('e.isArchived = true') | ||
52 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | ||
53 | ->andWhere('e.isDeleted=false') | ||
54 | ->orderBy('e.createdAt', 'desc') | ||
55 | ->getQuery(); | ||
56 | |||
57 | $paginator = new Paginator($qb); | ||
58 | |||
59 | return $paginator; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Retrieves starred entries for a user | ||
64 | * | ||
65 | * @param $userId | ||
66 | * @param $firstResult | ||
67 | * @param int $maxResults | ||
68 | * @return Paginator | ||
69 | */ | ||
70 | public function findStarredByUser($userId, $firstResult, $maxResults = 12) | ||
71 | { | ||
72 | $qb = $this->createQueryBuilder('e') | ||
73 | ->select('e') | ||
74 | ->setFirstResult($firstResult) | ||
75 | ->setMaxResults($maxResults) | ||
76 | ->where('e.isStarred = true') | ||
77 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | ||
78 | ->andWhere('e.isDeleted=false') | ||
79 | ->orderBy('e.createdAt', 'desc') | ||
80 | ->getQuery(); | ||
81 | |||
82 | $paginator = new Paginator($qb); | ||
83 | |||
84 | return $paginator; | ||
85 | } | ||
86 | |||
87 | public function findEntries($userId, $isArchived, $isStarred, $isDeleted, $sort, $order) | ||
88 | { | ||
89 | $qb = $this->createQueryBuilder('e') | ||
90 | ->select('e') | ||
91 | ->where('e.userId =:userId')->setParameter('userId', $userId); | ||
92 | |||
93 | if (!is_null($isArchived)) { | ||
94 | $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', $isArchived); | ||
95 | } | ||
96 | |||
97 | if (!is_null($isStarred)) { | ||
98 | $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', $isStarred); | ||
99 | } | ||
100 | |||
101 | if (!is_null($isDeleted)) { | ||
102 | $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted); | ||
103 | } | ||
104 | |||
105 | if ('created' === $sort) { | ||
106 | $qb->orderBy('e.createdAt', $order); | ||
107 | } elseif ('updated' === $sort) { | ||
108 | $qb->orderBy('e.updatedAt', $order); | ||
109 | } | ||
110 | |||
111 | return $qb | ||
112 | ->getQuery() | ||
113 | ->getResult(Query::HYDRATE_ARRAY); | ||
114 | } | ||
115 | } | ||