mirror of
https://github.com/wallabag/wallabag.git
synced 2024-06-03 05:49:22 +00:00
34be2d5de4
- 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)
40 lines
1.1 KiB
PHP
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',
|
|
]
|
|
);
|
|
}
|
|
}
|