diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-08-23 11:51:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-23 11:51:13 +0200 |
commit | 1bee9e0760c89756ebab0b67f9ab7efc5c6a709b (patch) | |
tree | cd6200f084675195aaa5789a3d0e1297eca1a94a /src/Wallabag/CoreBundle/Controller | |
parent | 79efca1e6ff28362d4bd2713f68205294cdd07de (diff) | |
parent | 97e7ad4dc7bfc26cea334bc880a39e388d6848f3 (diff) | |
download | wallabag-1bee9e0760c89756ebab0b67f9ab7efc5c6a709b.tar.gz wallabag-1bee9e0760c89756ebab0b67f9ab7efc5c6a709b.tar.zst wallabag-1bee9e0760c89756ebab0b67f9ab7efc5c6a709b.zip |
Merge pull request #2218 from wallabag/api-delete-tags-1982
Delete tag or tags by label
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 6 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ExportController.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/TagController.php | 44 |
3 files changed, 48 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index ccdf9406..93db0d6c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Controller; | |||
4 | 4 | ||
5 | use Pagerfanta\Adapter\DoctrineORMAdapter; | 5 | use Pagerfanta\Adapter\DoctrineORMAdapter; |
6 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; | 6 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; |
7 | use Pagerfanta\Pagerfanta; | ||
8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
9 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
10 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
@@ -257,9 +256,10 @@ class EntryController extends Controller | |||
257 | } | 256 | } |
258 | 257 | ||
259 | $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); | 258 | $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); |
260 | $entries = new Pagerfanta($pagerAdapter); | ||
261 | 259 | ||
262 | $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); | 260 | $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') |
261 | ->prepare($pagerAdapter, $page); | ||
262 | |||
263 | try { | 263 | try { |
264 | $entries->setCurrentPage($page); | 264 | $entries->setCurrentPage($page); |
265 | } catch (OutOfRangeCurrentPageException $e) { | 265 | } catch (OutOfRangeCurrentPageException $e) { |
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 944c755d..959b308d 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php | |||
@@ -46,7 +46,7 @@ class ExportController extends Controller | |||
46 | * | 46 | * |
47 | * @Route("/export/{category}.{format}", name="export_entries", requirements={ | 47 | * @Route("/export/{category}.{format}", name="export_entries", requirements={ |
48 | * "format": "epub|mobi|pdf|json|xml|txt|csv", | 48 | * "format": "epub|mobi|pdf|json|xml|txt|csv", |
49 | * "category": "all|unread|starred|archive" | 49 | * "category": "all|unread|starred|archive|tag_entries" |
50 | * }) | 50 | * }) |
51 | * | 51 | * |
52 | * @return \Symfony\Component\HttpFoundation\Response | 52 | * @return \Symfony\Component\HttpFoundation\Response |
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index 8645fb44..1cbc413d 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php | |||
@@ -2,12 +2,15 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Controller; | 3 | namespace Wallabag\CoreBundle\Controller; |
4 | 4 | ||
5 | use Pagerfanta\Adapter\ArrayAdapter; | ||
6 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; | ||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 10 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Entity\Tag; | 11 | use Wallabag\CoreBundle\Entity\Tag; |
10 | use Wallabag\CoreBundle\Form\Type\NewTagType; | 12 | use Wallabag\CoreBundle\Form\Type\NewTagType; |
13 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
11 | 14 | ||
12 | class TagController extends Controller | 15 | class TagController extends Controller |
13 | { | 16 | { |
@@ -90,4 +93,45 @@ 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 | $entriesByTag = $this->getDoctrine() | ||
109 | ->getRepository('WallabagCoreBundle:Entry') | ||
110 | ->findAllByTagId($this->getUser()->getId(), $tag->getId()); | ||
111 | |||
112 | $pagerAdapter = new ArrayAdapter($entriesByTag); | ||
113 | |||
114 | $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') | ||
115 | ->prepare($pagerAdapter, $page); | ||
116 | |||
117 | try { | ||
118 | $entries->setCurrentPage($page); | ||
119 | } catch (OutOfRangeCurrentPageException $e) { | ||
120 | if ($page > 1) { | ||
121 | return $this->redirect($this->generateUrl($request->get('_route'), [ | ||
122 | 'slug' => $tag->getSlug(), | ||
123 | 'page' => $entries->getNbPages(), | ||
124 | ]), 302); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | return $this->render( | ||
129 | 'WallabagCoreBundle:Entry:entries.html.twig', | ||
130 | [ | ||
131 | 'form' => null, | ||
132 | 'entries' => $entries, | ||
133 | 'currentPage' => $page, | ||
134 | ] | ||
135 | ); | ||
136 | } | ||
93 | } | 137 | } |