mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Merge pull request #5673 from wallabag/api-config-endpoint
Add new endpoint for API: config
This commit is contained in:
commit
3818cfe15f
4 changed files with 100 additions and 0 deletions
32
src/Wallabag/ApiBundle/Controller/ConfigRestController.php
Normal file
32
src/Wallabag/ApiBundle/Controller/ConfigRestController.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\ApiBundle\Controller;
|
||||
|
||||
use JMS\Serializer\SerializationContext;
|
||||
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();
|
||||
|
||||
$json = $this->get('jms_serializer')->serialize(
|
||||
$this->getUser()->getConfig(),
|
||||
'json',
|
||||
SerializationContext::create()->setGroups(['config_api'])
|
||||
);
|
||||
|
||||
return (new JsonResponse())
|
||||
->setJson($json)
|
||||
->setStatusCode(JsonResponse::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -32,3 +32,8 @@ user:
|
|||
type: rest
|
||||
resource: "WallabagApiBundle:UserRest"
|
||||
name_prefix: api_
|
||||
|
||||
config:
|
||||
type: rest
|
||||
resource: "WallabagApiBundle:ConfigRest"
|
||||
name_prefix: api_
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity;
|
|||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
|
@ -29,6 +30,8 @@ class Config
|
|||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
|
@ -50,6 +53,8 @@ class Config
|
|||
* maxMessage = "validator.item_per_page_too_high"
|
||||
* )
|
||||
* @ORM\Column(name="items_per_page", type="integer", nullable=false)
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $itemsPerPage;
|
||||
|
||||
|
@ -58,6 +63,8 @@ class Config
|
|||
*
|
||||
* @Assert\NotBlank()
|
||||
* @ORM\Column(name="language", type="string", nullable=false)
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $language;
|
||||
|
||||
|
@ -65,6 +72,8 @@ class Config
|
|||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="feed_token", type="string", nullable=true)
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $feedToken;
|
||||
|
||||
|
@ -77,6 +86,8 @@ class Config
|
|||
* max = 100000,
|
||||
* maxMessage = "validator.feed_limit_too_high"
|
||||
* )
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $feedLimit;
|
||||
|
||||
|
@ -84,6 +95,8 @@ class Config
|
|||
* @var float
|
||||
*
|
||||
* @ORM\Column(name="reading_speed", type="float", nullable=true)
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $readingSpeed;
|
||||
|
||||
|
@ -98,6 +111,8 @@ class Config
|
|||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="action_mark_as_read", type="integer", nullable=true, options={"default" = 0})
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $actionMarkAsRead;
|
||||
|
||||
|
@ -105,6 +120,8 @@ class Config
|
|||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="list_mode", type="integer", nullable=true)
|
||||
*
|
||||
* @Groups({"config_api"})
|
||||
*/
|
||||
private $listMode;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue