diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/CoreBundle/Controller/ExportController.php | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ExportController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ExportController.php | 20 |
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; | |||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
9 | use Wallabag\CoreBundle\Entity\Entry; | 9 | use Wallabag\CoreBundle\Entity\Entry; |
10 | use 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()); |