1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Superdesk Web Publisher Settings Bundle. |
7
|
|
|
* |
8
|
|
|
* Copyright 2017 Sourcefabric z.ú. and contributors. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please see the |
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* @copyright 2017 Sourcefabric z.ú |
14
|
|
|
* @license http://www.superdesk.org/license |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace SWP\Bundle\CoreBundle\Controller; |
18
|
|
|
|
19
|
|
|
use Nelmio\ApiDocBundle\Annotation\Model; |
20
|
|
|
use SWP\Bundle\SettingsBundle\Form\Type\BulkSettingsUpdateType; |
21
|
|
|
use SWP\Bundle\SettingsBundle\Form\Type\SettingType; |
22
|
|
|
use SWP\Bundle\SettingsBundle\Controller\SettingsController as BaseController; |
23
|
|
|
use Nelmio\ApiDocBundle\Annotation\Operation; |
24
|
|
|
use Swagger\Annotations as SWG; |
25
|
|
|
use SWP\Component\Common\Response\SingleResourceResponseInterface; |
26
|
|
|
use Symfony\Component\HttpFoundation\Request; |
27
|
|
|
|
28
|
|
|
class SettingsController extends BaseController |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @Operation( |
32
|
|
|
* tags={"settings"}, |
33
|
|
|
* summary="Lists all settings", |
34
|
|
|
* @SWG\Response( |
35
|
|
|
* response="200", |
36
|
|
|
* description="Returned on success.", |
37
|
|
|
* @SWG\Schema( |
38
|
|
|
* type="array", |
39
|
|
|
* @SWG\Items(ref=@Model(type=\SWP\Bundle\CoreBundle\Model\Settings::class, groups={"api"})) |
40
|
|
|
* ) |
41
|
|
|
* ) |
42
|
|
|
* ) |
43
|
|
|
*/ |
44
|
|
|
public function listAction(): SingleResourceResponseInterface |
45
|
|
|
{ |
46
|
|
|
return $this->list(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @Operation( |
51
|
|
|
* tags={"settings"}, |
52
|
|
|
* summary="Revert settings to defaults by scope", |
53
|
|
|
* @SWG\Response( |
54
|
|
|
* response="204", |
55
|
|
|
* description="Returned on success." |
56
|
|
|
* ) |
57
|
|
|
* ) |
58
|
|
|
*/ |
59
|
|
|
public function revertAction(string $scope): SingleResourceResponseInterface |
60
|
|
|
{ |
61
|
|
|
return $this->revert($scope); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @Operation( |
66
|
|
|
* tags={"settings"}, |
67
|
|
|
* summary="Change setting value", |
68
|
|
|
* @SWG\Parameter( |
69
|
|
|
* name="body", |
70
|
|
|
* in="body", |
71
|
|
|
* @SWG\Schema( |
72
|
|
|
* ref=@Model(type=SettingType::class) |
73
|
|
|
* ) |
74
|
|
|
* ), |
75
|
|
|
* @SWG\Response( |
76
|
|
|
* response="200", |
77
|
|
|
* description="Returned on success.", |
78
|
|
|
* @Model(type=\SWP\Bundle\CoreBundle\Model\Settings::class, groups={"api"}) |
79
|
|
|
* ), |
80
|
|
|
* @SWG\Response( |
81
|
|
|
* response="404", |
82
|
|
|
* description="Setting not found" |
83
|
|
|
* ) |
84
|
|
|
* ) |
85
|
|
|
*/ |
86
|
|
|
public function updateAction(Request $request): SingleResourceResponseInterface |
87
|
|
|
{ |
88
|
|
|
return $this->update($request); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @Operation( |
93
|
|
|
* tags={"settings"}, |
94
|
|
|
* summary="Settings bulk update", |
95
|
|
|
* @SWG\Parameter( |
96
|
|
|
* name="body", |
97
|
|
|
* in="body", |
98
|
|
|
* @SWG\Schema( |
99
|
|
|
* ref=@Model(type=BulkSettingsUpdateType::class) |
100
|
|
|
* ) |
101
|
|
|
* ), |
102
|
|
|
* @SWG\Response( |
103
|
|
|
* response="200", |
104
|
|
|
* description="Returned on success.", |
105
|
|
|
* @SWG\Schema( |
106
|
|
|
* type="array", |
107
|
|
|
* @SWG\Items(ref=@Model(type=\SWP\Bundle\CoreBundle\Model\Settings::class, groups={"api"})) |
108
|
|
|
* ) |
109
|
|
|
* ), |
110
|
|
|
* @SWG\Response( |
111
|
|
|
* response="404", |
112
|
|
|
* description="Setting not found" |
113
|
|
|
* ) |
114
|
|
|
* ) |
115
|
|
|
*/ |
116
|
|
|
public function bulkAction(Request $request): SingleResourceResponseInterface |
117
|
|
|
{ |
118
|
|
|
return $this->bulk($request); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|