]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
API: getEntry can return EPUB
authorPascal MARTIN <pmartin@tea-ebook.com>
Tue, 4 Oct 2016 11:57:18 +0000 (13:57 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 8 Oct 2016 10:05:41 +0000 (12:05 +0200)
src/Wallabag/ApiBundle/Controller/WallabagRestController.php

index a0d9d4f3a144336735468ad3fd4f04b67eda8087..072e5f85115ab91ab931a2d67eb97dc2030fc030 100644 (file)
@@ -127,11 +127,18 @@ class WallabagRestController extends FOSRestController
      *
      * @return JsonResponse
      */
-    public function getEntryAction(Entry $entry)
+    public function getEntryAction(Entry $entry, $_format)
     {
         $this->validateAuthentication();
         $this->validateUserAccess($entry->getUser()->getId());
 
+        if ($_format === 'epub') {
+            return $this->get('wallabag_core.helper.entries_export')
+                ->setEntries($entry)
+                ->updateTitle('entry')
+                ->exportAs($_format);
+        }
+
         $json = $this->get('serializer')->serialize($entry, 'json');
 
         return (new JsonResponse())->setJson($json);