aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/TagRepository.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-29 14:50:52 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-29 14:50:52 +0100
commitfc73222723c7a0c9b577805d3ef51eb96b124b92 (patch)
tree002b77b82266b1e497e3683e72f4a457d4353633 /src/Wallabag/CoreBundle/Repository/TagRepository.php
parentc997cfcc9c161241a6398b0942a1a869688d807a (diff)
downloadwallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.tar.gz
wallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.tar.zst
wallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.zip
Remove user reference in tag
Fix #1543
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/TagRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index ac3145a1..c4aeb594 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -9,16 +9,29 @@ use Pagerfanta\Pagerfanta;
9class TagRepository extends EntityRepository 9class TagRepository extends EntityRepository
10{ 10{
11 /** 11 /**
12 * Find Tags. 12 * Return only the QueryBuilder to retrieve all tags for a given user.
13 * 13 *
14 * @param int $userId 14 * @param int $userId
15 * 15 *
16 * @return array 16 * @return QueryBuilder
17 */
18 private function getQbForAllTags($userId)
19 {
20 return $this->createQueryBuilder('t')
21 ->leftJoin('t.entries', 'e')
22 ->where('e.user = :userId')->setParameter('userId', $userId);
23 }
24
25 /**
26 * Find Tags and return a Pager.
27 *
28 * @param int $userId
29 *
30 * @return Pagerfanta
17 */ 31 */
18 public function findTags($userId) 32 public function findTags($userId)
19 { 33 {
20 $qb = $this->createQueryBuilder('t') 34 $qb = $this->getQbForAllTags($userId);
21 ->where('t.user =:userId')->setParameter('userId', $userId);
22 35
23 $pagerAdapter = new DoctrineORMAdapter($qb); 36 $pagerAdapter = new DoctrineORMAdapter($qb);
24 37
@@ -26,19 +39,16 @@ class TagRepository extends EntityRepository
26 } 39 }
27 40
28 /** 41 /**
29 * Find a tag by its label and its owner. 42 * Find Tags.
30 * 43 *
31 * @param string $label 44 * @param int $userId
32 * @param int $userId
33 * 45 *
34 * @return Tag|null 46 * @return array
35 */ 47 */
36 public function findOneByLabelAndUserId($label, $userId) 48 public function findAllTags($userId)
37 { 49 {
38 return $this->createQueryBuilder('t') 50 return $this->getQbForAllTags($userId)
39 ->where('t.label = :label')->setParameter('label', $label)
40 ->andWhere('t.user = :user_id')->setParameter('user_id', $userId)
41 ->getQuery() 51 ->getQuery()
42 ->getOneOrNullResult(); 52 ->getResult();
43 } 53 }
44} 54}