]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #2453 from wallabag/fix-api-export
authorNicolas LÅ“uillet <nicolas@loeuillet.org>
Fri, 21 Oct 2016 13:22:11 +0000 (15:22 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Oct 2016 13:22:11 +0000 (15:22 +0200)
Fix API export

app/config/config.yml
app/config/routing_rest.yml
composer.json
src/Wallabag/ApiBundle/Controller/WallabagRestController.php

index 2f102c45c6af9dadb068b470f9f5e31cb76c0919..b4760073b128111c9d9f815fb3fae0d516fc3aa2 100644 (file)
@@ -112,12 +112,26 @@ swiftmailer:
 fos_rest:
     param_fetcher_listener: true
     body_listener: true
-    format_listener: true
     view:
+        mime_types:
+            csv:
+                - 'text/csv'
+                - 'text/plain'
+            pdf:
+                - 'application/pdf'
+            epub:
+                - 'application/epub+zip'
+            mobi:
+                - 'application/x-mobipocket-ebook'
         view_response_listener: 'force'
         formats:
             xml: true
-            json : true
+            json: true
+            txt: true
+            csv: true
+            pdf: true
+            epub: true
+            mobi: true
         templating_formats:
             html: true
         force_redirects:
@@ -126,6 +140,15 @@ fos_rest:
         default_engine: twig
     routing_loader:
         default_format: json
+    format_listener:
+        enabled: true
+        rules:
+            - { path: "^/api/entries/([0-9]+)/export.(.*)", priorities: ['epub', 'mobi', 'pdf', 'txt', 'csv'], fallback_format: false, prefer_extension: false }
+            - { path: "^/api", priorities: ['json', 'xml'], fallback_format: false, prefer_extension: false }
+            - { path: "^/annotations", priorities: ['json', 'xml'], fallback_format: false, prefer_extension: false }
+            # for an unknown reason, EACH REQUEST goes to FOS\RestBundle\EventListener\FormatListener
+            # so we need to add custom rule for custom api export but also for all other routes of the application...
+            - { path: '^/', priorities: ['text/html', '*/*'], fallback_format: html, prefer_extension: false }
 
 nelmio_api_doc:
     sandbox:
index 52d395dd9029066c18bf1e9483057a15d2601f47..29f4ab14c3ca09f35f201b611acfd6cc42b9d9f6 100644 (file)
@@ -1,4 +1,3 @@
 Rest_Wallabag:
-  type : rest
-  resource: "@WallabagApiBundle/Resources/config/routing_rest.yml"
-
+    type : rest
+    resource: "@WallabagApiBundle/Resources/config/routing_rest.yml"
index 79de337bada8f38cbd5a9e69c393f5be993a0bfc..4f7ad2915747c735b9614b02f069c4ab2c971ae3 100644 (file)
@@ -54,8 +54,8 @@
         "sensio/framework-extra-bundle": "^3.0.2",
         "incenteev/composer-parameter-handler": "^2.0",
         "nelmio/cors-bundle": "~1.4.0",
-        "friendsofsymfony/rest-bundle": "~1.4",
-        "jms/serializer-bundle": "~1.0",
+        "friendsofsymfony/rest-bundle": "~2.1",
+        "jms/serializer-bundle": "~1.1",
         "nelmio/api-doc-bundle": "~2.7",
         "mgargano/simplehtmldom": "~1.5",
         "tecnickcom/tcpdf": "~6.2",
index fa573988b9c90b60628514850e4e5e9d633d7d2f..3437bb9b96d937d836d3268e5eabcff2c894ad17 100644 (file)
@@ -12,7 +12,6 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\Tag;
-use FOS\RestBundle\Controller\Annotations\Route;
 
 class WallabagRestController extends FOSRestController
 {
@@ -167,8 +166,6 @@ class WallabagRestController extends FOSRestController
      *      }
      * )
      *
-     * @Route(requirements={"_format"="epub|mobi|pdf|txt|csv"})
-     *
      * @return Response
      */
     public function getEntryExportAction(Entry $entry, Request $request)