- $tags = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Tag')
- ->findAllTags($this->getUser()->getId());
-
- $flatTags = [];
-
- foreach ($tags as $key => $tag) {
- $nbEntries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag['id']);
-
- $flatTags[] = [
- 'id' => $tag['id'],
- 'label' => $tag['label'],
- 'slug' => $tag['slug'],
- 'nbEntries' => $nbEntries,
- ];
- }
+ $tags = $this->get('wallabag_core.tag_repository')
+ ->findAllFlatTagsWithNbEntries($this->getUser()->getId());