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-11-06 12:00:41 +00:00
|
|
|
use Nelmio\ApiDocBundle\Annotation\Operation;
|
|
|
|
use Swagger\Annotations as SWG;
|
2022-03-15 09:18:28 +00:00
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
2022-11-23 11:44:55 +00:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2022-03-15 09:18:28 +00:00
|
|
|
|
|
|
|
class ConfigRestController extends WallabagRestController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Retrieve configuration for current user.
|
|
|
|
*
|
2022-11-06 12:00:41 +00:00
|
|
|
* @Operation(
|
|
|
|
* tags={"Config"},
|
|
|
|
* summary="Retrieve configuration for current user.",
|
|
|
|
* @SWG\Response(
|
|
|
|
* response="200",
|
|
|
|
* description="Returned when successful"
|
|
|
|
* )
|
|
|
|
* )
|
2022-03-15 09:18:28 +00:00
|
|
|
*
|
2022-11-23 11:44:55 +00:00
|
|
|
* @Route("/api/config.{_format}", methods={"GET"}, name="api_get_config", defaults={"_format": "json"})
|
|
|
|
*
|
2022-03-15 09:18:28 +00:00
|
|
|
* @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
|
|
|
}
|
|
|
|
}
|