aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
diff options
context:
space:
mode:
authorlizyn <zhiylin@outlook.com>2020-02-24 10:04:13 +0800
committerGitHub <noreply@github.com>2020-02-24 10:04:13 +0800
commitb19df31d78d881a43bcf6b3215e5fc3781e8e8aa (patch)
treed0d9861694a4b5e5fbfdbeb53c255ecd15fe9328 /src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
parent4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff)
parent04d918cae0227c06a41d27fb6533dddbf30dfe71 (diff)
downloadwallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.gz
wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.zst
wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.zip
Merge pull request #1 from wallabag/master
Keep up with the master again
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
new file mode 100644
index 00000000..2496298a
--- /dev/null
+++ b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
@@ -0,0 +1,39 @@
1<?php
2
3namespace Wallabag\ApiBundle\Controller;
4
5use JMS\Serializer\SerializationContext;
6use JMS\Serializer\SerializerBuilder;
7use Nelmio\ApiDocBundle\Annotation\ApiDoc;
8use Symfony\Component\HttpFoundation\Response;
9
10class TaggingRuleRestController extends WallabagRestController
11{
12 /**
13 * Export all tagging rules as a json file.
14 *
15 * @ApiDoc()
16 *
17 * @return Response
18 */
19 public function getTaggingruleExportAction()
20 {
21 $this->validateAuthentication();
22
23 $data = SerializerBuilder::create()->build()->serialize(
24 $this->getUser()->getConfig()->getTaggingRules(),
25 'json',
26 SerializationContext::create()->setGroups(['export_tagging_rule'])
27 );
28
29 return Response::create(
30 $data,
31 200,
32 [
33 'Content-type' => 'application/json',
34 'Content-Disposition' => 'attachment; filename="tagging_rules_' . $this->getUser()->getUsername() . '.json"',
35 'Content-Transfer-Encoding' => 'UTF-8',
36 ]
37 );
38 }
39}