X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FExportController.php;h=7ca89239430dc7b2ec3da1d18fd1b88779ee944e;hb=3ef055ced3d6ea0d2f15ba660602545f477e9c3c;hp=6191d5d7973241f4582007b1db063766856e9f9b;hpb=d7b4b2c72cd1c9ad967ecfec668d5b0b9e794149;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 6191d5d7..7ca89239 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Wallabag\CoreBundle\Entity\Entry; @@ -32,6 +33,7 @@ class ExportController extends Controller return $this->get('wallabag_core.helper.entries_export') ->setEntries($entry) ->updateTitle('entry') + ->updateAuthor('entry') ->exportAs($format); } catch (\InvalidArgumentException $e) { throw new NotFoundHttpException($e->getMessage()); @@ -46,25 +48,36 @@ class ExportController extends Controller * * @Route("/export/{category}.{format}", name="export_entries", requirements={ * "format": "epub|mobi|pdf|json|xml|txt|csv", - * "category": "all|unread|starred|archive|tag_entries|untagged" + * "category": "all|unread|starred|archive|tag_entries|untagged|search" * }) * * @return \Symfony\Component\HttpFoundation\Response */ - public function downloadEntriesAction($format, $category) + public function downloadEntriesAction(Request $request, $format, $category) { $method = ucfirst($category); - $methodBuilder = 'getBuilderFor'.$method.'ByUser'; - $entries = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->$methodBuilder($this->getUser()->getId()) - ->getQuery() - ->getResult(); + $methodBuilder = 'getBuilderFor' . $method . 'ByUser'; + $repository = $this->get('wallabag_core.entry_repository'); + + if ('tag_entries' === $category) { + $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag')); + + $entries = $repository->findAllByTagId( + $this->getUser()->getId(), + $tag->getId() + ); + } else { + $entries = $repository + ->$methodBuilder($this->getUser()->getId()) + ->getQuery() + ->getResult(); + } try { return $this->get('wallabag_core.helper.entries_export') ->setEntries($entries) ->updateTitle($method) + ->updateAuthor($method) ->exportAs($format); } catch (\InvalidArgumentException $e) { throw new NotFoundHttpException($e->getMessage());