aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/TagController.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-14 15:03:22 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-08-23 07:24:42 +0200
commit891456ba9a592a200d8b23029e8f4514d9803080 (patch)
tree99b91dd57ab3db4a4a621cfd7c84ec7fab1d30ae /src/Wallabag/CoreBundle/Controller/TagController.php
parent79efca1e6ff28362d4bd2713f68205294cdd07de (diff)
downloadwallabag-891456ba9a592a200d8b23029e8f4514d9803080.tar.gz
wallabag-891456ba9a592a200d8b23029e8f4514d9803080.tar.zst
wallabag-891456ba9a592a200d8b23029e8f4514d9803080.zip
Links on each tag in Tags view
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/TagController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 8645fb44..b6514ea6 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -2,12 +2,15 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\ArrayAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 8use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
10use Wallabag\CoreBundle\Form\Type\NewTagType; 12use Wallabag\CoreBundle\Form\Type\NewTagType;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
11 14
12class TagController extends Controller 15class TagController extends Controller
13{ 16{
@@ -90,4 +93,41 @@ class TagController extends Controller
90 ] 93 ]
91 ); 94 );
92 } 95 }
96
97 /**
98 * @param Tag $tag
99 * @param int $page
100 *
101 * @Route("/tag/list/{slug}/{page}", name="tag_entries", defaults={"page" = "1"})
102 * @ParamConverter("tag", options={"mapping": {"slug": "slug"}})
103 *
104 * @return \Symfony\Component\HttpFoundation\Response
105 */
106 public function showEntriesForTagAction(Tag $tag, $page, Request $request)
107 {
108 $pagerAdapter = new ArrayAdapter($tag->getEntries()->toArray());
109
110 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')
111 ->prepare($pagerAdapter, $page);
112
113 try {
114 $entries->setCurrentPage($page);
115 } catch (OutOfRangeCurrentPageException $e) {
116 if ($page > 1) {
117 return $this->redirect($this->generateUrl($request->get('_route'), [
118 'slug' => $tag->getSlug(),
119 'page' => $entries->getNbPages(),
120 ]), 302);
121 }
122 }
123
124 return $this->render(
125 'WallabagCoreBundle:Entry:entries.html.twig',
126 [
127 'form' => null,
128 'entries' => $entries,
129 'currentPage' => $page,
130 ]
131 );
132 }
93} 133}