aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/AnnotationBundle/Repository
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-10-23 11:09:17 +0200
committerGitHub <noreply@github.com>2017-10-23 11:09:17 +0200
commit1953a872932a63792293b4aec087880265ba89f7 (patch)
treefd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/AnnotationBundle/Repository
parentd83d25dadec2c38460a32d96f5d2903426fec9d3 (diff)
parent702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff)
downloadwallabag-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.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}