aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 11:21:13 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:03:49 +0200
commitfaa86e06ba3032fdb98f3c0f79c72e8581d3c96f (patch)
treefbb850231bcdf3e24445c3e73499114e6f30f49c /src/Wallabag/CoreBundle/Repository
parent9d7dd6b0d2480d3efff5b0ab1461f2ef99bfd57a (diff)
downloadwallabag-faa86e06ba3032fdb98f3c0f79c72e8581d3c96f.tar.gz
wallabag-faa86e06ba3032fdb98f3c0f79c72e8581d3c96f.tar.zst
wallabag-faa86e06ba3032fdb98f3c0f79c72e8581d3c96f.zip
Fix tags count in menu
Move enable cache for Tag in the Entity because function `find*` should return result and not a Query
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository')
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index 41f61607..f5c4ea6a 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -7,17 +7,45 @@ use Doctrine\ORM\EntityRepository;
7class TagRepository extends EntityRepository 7class TagRepository extends EntityRepository
8{ 8{
9 /** 9 /**
10 * Find Tags. 10 * Find all tags per user.
11 * 11 *
12 * @param int $userId 12 * @param int $userId
13 * @param int $cacheLifeTime Duration of the cache for this query
13 * 14 *
14 * @return array 15 * @return array
15 */ 16 */
16 public function findAllTags($userId) 17 public function findAllTags($userId, $cacheLifeTime = null)
18 {
19 $query = $this->createQueryBuilder('t')
20 ->select('t')
21 ->leftJoin('t.entries', 'e')
22 ->where('e.user = :userId')->setParameter('userId', $userId)
23 ->groupBy('t.slug')
24 ->getQuery();
25
26 if (null !== $cacheLifeTime) {
27 $query->useQueryCache(true);
28 $query->useResultCache(true);
29 $query->setResultCacheLifetime($cacheLifeTime);
30 }
31
32 return $query->getArrayResult();
33 }
34
35 /**
36 * Find all tags with associated entries per user.
37 *
38 * @param int $userId
39 *
40 * @return array
41 */
42 public function findAllTagsWithEntries($userId)
17 { 43 {
18 return $this->createQueryBuilder('t') 44 return $this->createQueryBuilder('t')
19 ->leftJoin('t.entries', 'e') 45 ->leftJoin('t.entries', 'e')
20 ->where('e.user = :userId')->setParameter('userId', $userId); 46 ->where('e.user = :userId')->setParameter('userId', $userId)
47 ->getQuery()
48 ->getResult();
21 } 49 }
22 50
23 /** 51 /**