aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Twig/WallabagExtension.php')
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index 3780b13e..fb4c7412 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -2,7 +2,6 @@
2 2
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Doctrine\ORM\Query;
6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Wallabag\CoreBundle\Repository\EntryRepository; 6use Wallabag\CoreBundle\Repository\EntryRepository;
8use Wallabag\CoreBundle\Repository\TagRepository; 7use Wallabag\CoreBundle\Repository\TagRepository;
@@ -85,10 +84,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
85 ->groupBy('e.id') 84 ->groupBy('e.id')
86 ->getQuery(); 85 ->getQuery();
87 86
88 $data = $this->enableCache($query) 87 $query->useQueryCache(true);
89 ->getArrayResult(); 88 $query->useResultCache(true);
89 $query->setResultCacheLifetime($this->lifeTime);
90 90
91 return count($data); 91 return count($query->getArrayResult());
92 } 92 }
93 93
94 /** 94 /**
@@ -104,28 +104,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
104 return 0; 104 return 0;
105 } 105 }
106 106
107 $qb = $this->tagRepository->findAllTags($user->getId()); 107 return $this->tagRepository->countAllTags($user->getId());
108
109 $data = $this->enableCache($qb->getQuery())
110 ->getArrayResult();
111
112 return count($data);
113 }
114
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 } 108 }
130 109
131 public function getName() 110 public function getName()