]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
Update language in Entry model, and add index
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / TaggingRuleRestController.php
CommitLineData
34be2d5d
JB
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}