diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/AnnotationBundle/Repository | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'src/Wallabag/AnnotationBundle/Repository')
-rw-r--r-- | src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php | 51 |
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 @@ | |||
3 | namespace Wallabag\AnnotationBundle\Repository; | 3 | namespace Wallabag\AnnotationBundle\Repository; |
4 | 4 | ||
5 | use Doctrine\ORM\EntityRepository; | 5 | use Doctrine\ORM\EntityRepository; |
6 | use Doctrine\ORM\QueryBuilder; | ||
7 | use Wallabag\AnnotationBundle\Entity\Annotation; | ||
6 | 8 | ||
7 | /** | 9 | /** |
8 | * AnnotationRepository. | 10 | * AnnotationRepository. |
@@ -10,22 +12,6 @@ use Doctrine\ORM\EntityRepository; | |||
10 | class AnnotationRepository extends EntityRepository | 12 | class 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 | } |