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-08-28 00:01:46 +00:00
|
|
|
use JMS\Serializer\SerializerInterface;
|
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-08-28 00:01:46 +00:00
|
|
|
$json = $this->get(SerializerInterface::class)->serialize(
|
2022-03-15 09:44:32 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
}
|