wallabag/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
Jeremy Benoist 34be2d5de4
Add ability to import/export tagging rules
- Add missing translations
- Add some tests
- Add `/api/taggingrule/export` API endpoint
- Add baggy theme
- Add error message when importing tagging rules failed
- Also fix all translations (I think we are good now)
2019-07-08 09:38:32 +02:00

40 lines
1.1 KiB
PHP

<?php
namespace Wallabag\ApiBundle\Controller;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Response;
class TaggingRuleRestController extends WallabagRestController
{
/**
* Export all tagging rules as a json file.
*
* @ApiDoc()
*
* @return Response
*/
public function getTaggingruleExportAction()
{
$this->validateAuthentication();
$data = SerializerBuilder::create()->build()->serialize(
$this->getUser()->getConfig()->getTaggingRules(),
'json',
SerializationContext::create()->setGroups(['export_tagging_rule'])
);
return Response::create(
$data,
200,
[
'Content-type' => 'application/json',
'Content-Disposition' => 'attachment; filename="tagging_rules_' . $this->getUser()->getUsername() . '.json"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
}
}