aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Twig
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/Twig
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/Twig')
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index 3780b13e..0a6896c9 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -85,10 +85,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
85 ->groupBy('e.id') 85 ->groupBy('e.id')
86 ->getQuery(); 86 ->getQuery();
87 87
88 $data = $this->enableCache($query) 88 $query->useQueryCache(true);
89 ->getArrayResult(); 89 $query->useResultCache(true);
90 $query->setResultCacheLifetime($this->lifeTime);
90 91
91 return count($data); 92 return count($query->getArrayResult());
92 } 93 }
93 94
94 /** 95 /**
@@ -104,30 +105,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
104 return 0; 105 return 0;
105 } 106 }
106 107
107 $qb = $this->tagRepository->findAllTags($user->getId()); 108 $data = $this->tagRepository->findAllTags($user->getId());
108
109 $data = $this->enableCache($qb->getQuery())
110 ->getArrayResult();
111 109
112 return count($data); 110 return count($data);
113 } 111 }
114 112
115 /**
116 * Enable cache for a query.
117 *
118 * @param Query $query
119 *
120 * @return Query
121 */
122 private function enableCache(Query $query)
123 {
124 $query->useQueryCache(true);
125 $query->useResultCache(true);
126 $query->setResultCacheLifetime($this->lifeTime);
127
128 return $query;
129 }
130
131 public function getName() 113 public function getName()
132 { 114 {
133 return 'wallabag_extension'; 115 return 'wallabag_extension';