aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php')
-rw-r--r--src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
index 8d3f07ee..b44f7e64 100644
--- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
+++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
@@ -3,6 +3,8 @@
3namespace Wallabag\AnnotationBundle\Repository; 3namespace Wallabag\AnnotationBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Doctrine\ORM\QueryBuilder;
7use Wallabag\AnnotationBundle\Entity\Annotation;
6 8
7/** 9/**
8 * AnnotationRepository. 10 * AnnotationRepository.
@@ -10,22 +12,6 @@ use Doctrine\ORM\EntityRepository;
10class AnnotationRepository extends EntityRepository 12class AnnotationRepository extends EntityRepository
11{ 13{
12 /** 14 /**
13 * Return a query builder to used by other getBuilderFor* method.
14 *
15 * @param int $userId
16 *
17 * @return QueryBuilder
18 */
19 private function getBuilderByUser($userId)
20 {
21 return $this->createQueryBuilder('a')
22 ->leftJoin('a.user', 'u')
23 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
24 ->orderBy('a.id', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all annotations for a user. 15 * Retrieves all annotations for a user.
30 * 16 *
31 * @param int $userId 17 * @param int $userId
@@ -122,4 +108,37 @@ class AnnotationRepository extends EntityRepository
122 ->setParameter('userId', $userId) 108 ->setParameter('userId', $userId)
123 ->execute(); 109 ->execute();
124 } 110 }
111
112 /**
113 * Find all annotations related to archived entries.
114 *
115 * @param $userId
116 *
117 * @return mixed
118 */
119 public function findAllArchivedEntriesByUser($userId)
120 {
121 return $this->createQueryBuilder('a')
122 ->leftJoin('a.entry', 'e')
123 ->where('a.user = :userid')->setParameter(':userid', $userId)
124 ->andWhere('e.isArchived = true')
125 ->getQuery()
126 ->getResult();
127 }
128
129 /**
130 * Return a query builder to used by other getBuilderFor* method.
131 *
132 * @param int $userId
133 *
134 * @return QueryBuilder
135 */
136 private function getBuilderByUser($userId)
137 {
138 return $this->createQueryBuilder('a')
139 ->leftJoin('a.user', 'u')
140 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
141 ->orderBy('a.id', 'desc')
142 ;
143 }
125} 144}