Merge pull request #2013 from wallabag/fix-display-all-tags

Fix tags listing
This commit is contained in:
Jeremy Benoist 2016-05-03 10:07:34 +02:00
commit 97c8eb3c23
4 changed files with 6 additions and 36 deletions

View file

@ -81,7 +81,7 @@ class TagController extends Controller
{ {
$tags = $this->getDoctrine() $tags = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Tag') ->getRepository('WallabagCoreBundle:Tag')
->findTags($this->getUser()->getId()); ->findAllTags($this->getUser()->getId());
return $this->render( return $this->render(
'WallabagCoreBundle:Tag:tags.html.twig', 'WallabagCoreBundle:Tag:tags.html.twig',

View file

@ -3,41 +3,9 @@
namespace Wallabag\CoreBundle\Repository; namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
class TagRepository extends EntityRepository class TagRepository extends EntityRepository
{ {
/**
* Return only the QueryBuilder to retrieve all tags for a given user.
*
* @param int $userId
*
* @return QueryBuilder
*/
private function getQbForAllTags($userId)
{
return $this->createQueryBuilder('t')
->leftJoin('t.entries', 'e')
->where('e.user = :userId')->setParameter('userId', $userId);
}
/**
* Find Tags and return a Pager.
*
* @param int $userId
*
* @return Pagerfanta
*/
public function findTags($userId)
{
$qb = $this->getQbForAllTags($userId);
$pagerAdapter = new DoctrineORMAdapter($qb);
return new Pagerfanta($pagerAdapter);
}
/** /**
* Find Tags. * Find Tags.
* *
@ -47,7 +15,9 @@ class TagRepository extends EntityRepository
*/ */
public function findAllTags($userId) public function findAllTags($userId)
{ {
return $this->getQbForAllTags($userId) return $this->createQueryBuilder('t')
->leftJoin('t.entries', 'e')
->where('e.user = :userId')->setParameter('userId', $userId)
->getQuery() ->getQuery()
->getResult(); ->getResult();
} }

View file

@ -4,7 +4,7 @@
{% block content %} {% block content %}
<div class="results"> <div class="results">
<div class="nb-results">{{ 'tag.list.number_on_the_page'|transchoice(tags.count) }}</div> <div class="nb-results">{{ 'tag.list.number_on_the_page'|transchoice(tags|length) }}</div>
</div> </div>
<ul> <ul>

View file

@ -4,7 +4,7 @@
{% block content %} {% block content %}
<div class="results clearfix"> <div class="results clearfix">
<div class="nb-results left">{{ 'tag.list.number_on_the_page'|transchoice(tags.count) }}</div> <div class="nb-results left">{{ 'tag.list.number_on_the_page'|transchoice(tags|length) }}</div>
</div> </div>
<br /> <br />
<ul class="row data"> <ul class="row data">