wallabag/src/Wallabag/ApiBundle/Controller/ConfigRestController.php

33 lines
781 B
PHP
Raw Normal View History

2022-03-15 09:18:28 +00:00
<?php
namespace Wallabag\ApiBundle\Controller;
2022-03-15 09:44:32 +00:00
use JMS\Serializer\SerializationContext;
2022-03-15 09:18:28 +00:00
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\JsonResponse;
class ConfigRestController extends WallabagRestController
{
/**
* Retrieve configuration for current user.
*
* @ApiDoc()
*
* @return JsonResponse
*/
public function getConfigAction()
{
$this->validateAuthentication();
2022-03-15 09:44:32 +00:00
$json = $this->get('jms_serializer')->serialize(
$this->getUser()->getConfig(),
'json',
SerializationContext::create()->setGroups(['config_api'])
);
return (new JsonResponse())
->setJson($json)
->setStatusCode(JsonResponse::HTTP_OK);
2022-03-15 09:18:28 +00:00
}
}