aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/TagController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/TagController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 8a093289..a8b1eadd 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -28,7 +28,7 @@ class TagController extends Controller
28 $form->handleRequest($request); 28 $form->handleRequest($request);
29 29
30 if ($form->isSubmitted() && $form->isValid()) { 30 if ($form->isSubmitted() && $form->isValid()) {
31 $this->get('wallabag_core.content_proxy')->assignTagsToEntry( 31 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
32 $entry, 32 $entry,
33 $form->get('label')->getData() 33 $form->get('label')->getData()
34 ); 34 );
@@ -70,7 +70,7 @@ class TagController extends Controller
70 $em->flush(); 70 $em->flush();
71 } 71 }
72 72
73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); 73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true);
74 74
75 return $this->redirect($redirectUrl); 75 return $this->redirect($redirectUrl);
76 } 76 }
@@ -84,16 +84,17 @@ class TagController extends Controller
84 */ 84 */
85 public function showTagAction() 85 public function showTagAction()
86 { 86 {
87 $tags = $this->getDoctrine() 87 $repository = $this->get('wallabag_core.entry_repository');
88 ->getRepository('WallabagCoreBundle:Tag') 88 $tags = $this->get('wallabag_core.tag_repository')
89 ->findAllTags($this->getUser()->getId()); 89 ->findAllTags($this->getUser()->getId());
90 90
91 $flatTags = []; 91 $flatTags = [];
92 92
93 foreach ($tags as $tag) { 93 foreach ($tags as $tag) {
94 $nbEntries = $this->getDoctrine() 94 $nbEntries = $repository->countAllEntriesByUserIdAndTagId(
95 ->getRepository('WallabagCoreBundle:Entry') 95 $this->getUser()->getId(),
96 ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag->getId()); 96 $tag->getId()
97 );
97 98
98 $flatTags[] = [ 99 $flatTags[] = [
99 'id' => $tag->getId(), 100 'id' => $tag->getId(),
@@ -119,14 +120,14 @@ class TagController extends Controller
119 */ 120 */
120 public function showEntriesForTagAction(Tag $tag, $page, Request $request) 121 public function showEntriesForTagAction(Tag $tag, $page, Request $request)
121 { 122 {
122 $entriesByTag = $this->getDoctrine() 123 $entriesByTag = $this->get('wallabag_core.entry_repository')->findAllByTagId(
123 ->getRepository('WallabagCoreBundle:Entry') 124 $this->getUser()->getId(),
124 ->findAllByTagId($this->getUser()->getId(), $tag->getId()); 125 $tag->getId()
126 );
125 127
126 $pagerAdapter = new ArrayAdapter($entriesByTag); 128 $pagerAdapter = new ArrayAdapter($entriesByTag);
127 129
128 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') 130 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
129 ->prepare($pagerAdapter, $page);
130 131
131 try { 132 try {
132 $entries->setCurrentPage($page); 133 $entries->setCurrentPage($page);
@@ -143,7 +144,7 @@ class TagController extends Controller
143 'form' => null, 144 'form' => null,
144 'entries' => $entries, 145 'entries' => $entries,
145 'currentPage' => $page, 146 'currentPage' => $page,
146 'tag' => $tag->getSlug(), 147 'tag' => $tag,
147 ]); 148 ]);
148 } 149 }
149} 150}