X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FTwig%2FWallabagExtension.php;h=fb4c7412395f4affcb3b4b73f844ea06d498d4cc;hb=19ca0b2f355a657dd296bfa782473ffd45280572;hp=3780b13e7db5884abf3b9e156dff8db0e0b8c397;hpb=d7b4b2c72cd1c9ad967ecfec668d5b0b9e794149;p=github%2Fwallabag%2Fwallabag.git 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 @@ namespace Wallabag\CoreBundle\Twig; -use Doctrine\ORM\Query; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; @@ -85,10 +84,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa ->groupBy('e.id') ->getQuery(); - $data = $this->enableCache($query) - ->getArrayResult(); + $query->useQueryCache(true); + $query->useResultCache(true); + $query->setResultCacheLifetime($this->lifeTime); - return count($data); + return count($query->getArrayResult()); } /** @@ -104,28 +104,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return 0; } - $qb = $this->tagRepository->findAllTags($user->getId()); - - $data = $this->enableCache($qb->getQuery()) - ->getArrayResult(); - - return count($data); - } - - /** - * Enable cache for a query. - * - * @param Query $query - * - * @return Query - */ - private function enableCache(Query $query) - { - $query->useQueryCache(true); - $query->useResultCache(true); - $query->setResultCacheLifetime($this->lifeTime); - - return $query; + return $this->tagRepository->countAllTags($user->getId()); } public function getName()