aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ExportController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ExportController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index abc3336a..7ca89239 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -7,7 +7,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag;
11 10
12/** 11/**
13 * The try/catch can be removed once all formats will be implemented. 12 * The try/catch can be removed once all formats will be implemented.
@@ -34,6 +33,7 @@ class ExportController extends Controller
34 return $this->get('wallabag_core.helper.entries_export') 33 return $this->get('wallabag_core.helper.entries_export')
35 ->setEntries($entry) 34 ->setEntries($entry)
36 ->updateTitle('entry') 35 ->updateTitle('entry')
36 ->updateAuthor('entry')
37 ->exportAs($format); 37 ->exportAs($format);
38 } catch (\InvalidArgumentException $e) { 38 } catch (\InvalidArgumentException $e) {
39 throw new NotFoundHttpException($e->getMessage()); 39 throw new NotFoundHttpException($e->getMessage());
@@ -56,17 +56,18 @@ class ExportController extends Controller
56 public function downloadEntriesAction(Request $request, $format, $category) 56 public function downloadEntriesAction(Request $request, $format, $category)
57 { 57 {
58 $method = ucfirst($category); 58 $method = ucfirst($category);
59 $methodBuilder = 'getBuilderFor'.$method.'ByUser'; 59 $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
60 $repository = $this->get('wallabag_core.entry_repository');
60 61
61 if ($category == 'tag_entries') { 62 if ('tag_entries' === $category) {
62 $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneBySlug($request->query->get('tag')); 63 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
63 64
64 $entries = $this->getDoctrine() 65 $entries = $repository->findAllByTagId(
65 ->getRepository('WallabagCoreBundle:Entry') 66 $this->getUser()->getId(),
66 ->findAllByTagId($this->getUser()->getId(), $tag->getId()); 67 $tag->getId()
68 );
67 } else { 69 } else {
68 $entries = $this->getDoctrine() 70 $entries = $repository
69 ->getRepository('WallabagCoreBundle:Entry')
70 ->$methodBuilder($this->getUser()->getId()) 71 ->$methodBuilder($this->getUser()->getId())
71 ->getQuery() 72 ->getQuery()
72 ->getResult(); 73 ->getResult();
@@ -76,6 +77,7 @@ class ExportController extends Controller
76 return $this->get('wallabag_core.helper.entries_export') 77 return $this->get('wallabag_core.helper.entries_export')
77 ->setEntries($entries) 78 ->setEntries($entries)
78 ->updateTitle($method) 79 ->updateTitle($method)
80 ->updateAuthor($method)
79 ->exportAs($format); 81 ->exportAs($format);
80 } catch (\InvalidArgumentException $e) { 82 } catch (\InvalidArgumentException $e) {
81 throw new NotFoundHttpException($e->getMessage()); 83 throw new NotFoundHttpException($e->getMessage());