1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SoliDry\Documentation; |
4
|
|
|
|
5
|
|
|
use SoliDry\Extension\JSONApiInterface; |
6
|
|
|
use SoliDry\Helpers\Classes; |
7
|
|
|
use SoliDry\Helpers\MigrationsHelper; |
8
|
|
|
use SoliDry\Types\DefaultInterface; |
9
|
|
|
use SoliDry\Types\DocumentationInterface; |
10
|
|
|
use SoliDry\Types\PhpInterface; |
11
|
|
|
|
12
|
|
|
trait RelationsDoc |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Sets OAS documentation for a related method |
16
|
|
|
*/ |
17
|
|
|
private function setRelated(): void |
18
|
|
|
{ |
19
|
|
|
$this->openComment(); |
|
|
|
|
20
|
|
|
|
21
|
|
|
$this->setStarredComment(DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES); |
|
|
|
|
22
|
|
|
|
23
|
|
|
$this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH |
24
|
|
|
. MigrationsHelper::getTableName($this->generator->objectName) . PhpInterface::SLASH . '{id}/{related}",', 1, 1); |
25
|
|
|
|
26
|
|
|
$this->setStarredComment('summary="Get ' . Classes::getClassName($this->generator->objectName) . ' related objects",', 1, 1); |
27
|
|
|
|
28
|
|
|
$this->setStarredComment('tags={"' . Classes::getClassName($this->generator->objectName) . DefaultInterface::CONTROLLER_POSTFIX |
29
|
|
|
. '"},', 1, 1); |
30
|
|
|
|
31
|
|
|
$this->setParameter([ |
|
|
|
|
32
|
|
|
'in' => '"query"', |
33
|
|
|
'name' => '"data"', |
34
|
|
|
'required' => 'false', |
35
|
|
|
]); |
36
|
|
|
|
37
|
|
|
$this->setParameter([ |
38
|
|
|
'in' => '"path"', |
39
|
|
|
'name' => '"id"', |
40
|
|
|
'required' => 'true', |
41
|
|
|
]); |
42
|
|
|
|
43
|
|
|
$this->setParameter([ |
44
|
|
|
'in' => '"path"', |
45
|
|
|
'name' => '"related"', |
46
|
|
|
'required' => 'true', |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
$this->setResponse([ |
|
|
|
|
50
|
|
|
'response' => '"' . JSONApiInterface::HTTP_RESPONSE_CODE_OK . '"', |
51
|
|
|
'description' => '"' . self::SUCCESSFUL_OPERATION . '"', |
|
|
|
|
52
|
|
|
]); |
53
|
|
|
|
54
|
|
|
$this->setStarredComment(PhpInterface::CLOSE_PARENTHESES); |
55
|
|
|
|
56
|
|
|
$this->closeComment(); |
|
|
|
|
57
|
|
|
$this->setNewLines(); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Sets OAS documentation for getting relations method |
62
|
|
|
*/ |
63
|
|
|
private function setRelations(): void |
64
|
|
|
{ |
65
|
|
|
$this->openComment(); |
66
|
|
|
|
67
|
|
|
$this->setStarredComment(DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES); |
68
|
|
|
|
69
|
|
|
$this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH |
70
|
|
|
. MigrationsHelper::getTableName($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1); |
71
|
|
|
|
72
|
|
|
$this->setStarredComment('summary="Get ' . Classes::getClassName($this->generator->objectName) . ' relations objects",', 1, 1); |
73
|
|
|
|
74
|
|
|
$this->setStarredComment('tags={"' . Classes::getClassName($this->generator->objectName) . DefaultInterface::CONTROLLER_POSTFIX |
75
|
|
|
. '"},', 1, 1); |
76
|
|
|
|
77
|
|
|
$this->setParameter([ |
78
|
|
|
'in' => '"query"', |
79
|
|
|
'name' => '"data"', |
80
|
|
|
'required' => 'false', |
81
|
|
|
]); |
82
|
|
|
|
83
|
|
|
$this->setParameter([ |
84
|
|
|
'in' => '"path"', |
85
|
|
|
'name' => '"id"', |
86
|
|
|
'required' => 'true', |
87
|
|
|
]); |
88
|
|
|
|
89
|
|
|
$this->setParameter([ |
90
|
|
|
'in' => '"path"', |
91
|
|
|
'name' => '"relations"', |
92
|
|
|
'required' => 'true', |
93
|
|
|
]); |
94
|
|
|
|
95
|
|
|
$this->setResponse([ |
96
|
|
|
'response' => '"' . JSONApiInterface::HTTP_RESPONSE_CODE_OK . '"', |
97
|
|
|
'description' => '"' . self::SUCCESSFUL_OPERATION . '"', |
|
|
|
|
98
|
|
|
]); |
99
|
|
|
|
100
|
|
|
$this->setStarredComment(PhpInterface::CLOSE_PARENTHESES); |
101
|
|
|
|
102
|
|
|
$this->closeComment(); |
103
|
|
|
$this->setNewLines(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Sets OAS documentation for creating relation method |
108
|
|
|
*/ |
109
|
|
|
private function setCreateRelation(): void |
110
|
|
|
{ |
111
|
|
|
$this->openComment(); |
112
|
|
|
|
113
|
|
|
$this->setStarredComment(DocumentationInterface::OA_POST . PhpInterface::OPEN_PARENTHESES); |
114
|
|
|
|
115
|
|
|
$this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH |
116
|
|
|
. MigrationsHelper::getTableName($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1); |
117
|
|
|
|
118
|
|
|
$this->setStarredComment('summary="Create ' . Classes::getClassName($this->generator->objectName) . ' relation object",', 1, 1); |
119
|
|
|
|
120
|
|
|
$this->setStarredComment('tags={"' . Classes::getClassName($this->generator->objectName) . DefaultInterface::CONTROLLER_POSTFIX |
121
|
|
|
. '"},', 1, 1); |
122
|
|
|
|
123
|
|
|
$this->setParameter([ |
124
|
|
|
'in' => '"path"', |
125
|
|
|
'name' => '"id"', |
126
|
|
|
'required' => 'true', |
127
|
|
|
]); |
128
|
|
|
|
129
|
|
|
$this->setParameter([ |
130
|
|
|
'in' => '"path"', |
131
|
|
|
'name' => '"relations"', |
132
|
|
|
'required' => 'true', |
133
|
|
|
]); |
134
|
|
|
|
135
|
|
|
$this->setResponse([ |
136
|
|
|
'response' => '"' . JSONApiInterface::HTTP_RESPONSE_CODE_CREATED . '"', |
137
|
|
|
'description' => '"' . self::SUCCESSFUL_OPERATION . '"', |
|
|
|
|
138
|
|
|
]); |
139
|
|
|
|
140
|
|
|
$this->setStarredComment(PhpInterface::CLOSE_PARENTHESES); |
141
|
|
|
|
142
|
|
|
$this->closeComment(); |
143
|
|
|
$this->setNewLines(); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Sets OAS documentation for updating relation method |
148
|
|
|
*/ |
149
|
|
|
private function setUpdateRelation(): void |
150
|
|
|
{ |
151
|
|
|
$this->openComment(); |
152
|
|
|
|
153
|
|
|
$this->setStarredComment(DocumentationInterface::OA_PATCH . PhpInterface::OPEN_PARENTHESES); |
154
|
|
|
|
155
|
|
|
$this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH |
156
|
|
|
. MigrationsHelper::getTableName($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1); |
157
|
|
|
|
158
|
|
|
$this->setStarredComment('summary="Update ' . Classes::getClassName($this->generator->objectName) . ' relation object",', 1, 1); |
159
|
|
|
|
160
|
|
|
$this->setStarredComment('tags={"' . Classes::getClassName($this->generator->objectName) . DefaultInterface::CONTROLLER_POSTFIX |
161
|
|
|
. '"},', 1, 1); |
162
|
|
|
|
163
|
|
|
$this->setParameter([ |
164
|
|
|
'in' => '"path"', |
165
|
|
|
'name' => '"id"', |
166
|
|
|
'required' => 'true', |
167
|
|
|
]); |
168
|
|
|
|
169
|
|
|
$this->setParameter([ |
170
|
|
|
'in' => '"path"', |
171
|
|
|
'name' => '"relations"', |
172
|
|
|
'required' => 'true', |
173
|
|
|
]); |
174
|
|
|
|
175
|
|
|
$this->setResponse([ |
176
|
|
|
'response' => '"' . JSONApiInterface::HTTP_RESPONSE_CODE_OK . '"', |
177
|
|
|
'description' => '"' . self::SUCCESSFUL_OPERATION . '"', |
|
|
|
|
178
|
|
|
]); |
179
|
|
|
|
180
|
|
|
$this->setStarredComment(PhpInterface::CLOSE_PARENTHESES); |
181
|
|
|
|
182
|
|
|
$this->closeComment(); |
183
|
|
|
$this->setNewLines(); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Sets OAS documentation for deleting relation method |
188
|
|
|
*/ |
189
|
|
|
private function setDeleteRelation(): void |
190
|
|
|
{ |
191
|
|
|
$this->openComment(); |
192
|
|
|
|
193
|
|
|
$this->setStarredComment(DocumentationInterface::OA_DELETE . PhpInterface::OPEN_PARENTHESES); |
194
|
|
|
|
195
|
|
|
$this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH |
196
|
|
|
. MigrationsHelper::getTableName($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1); |
197
|
|
|
|
198
|
|
|
$this->setStarredComment('summary="Delete ' . Classes::getClassName($this->generator->objectName) . ' relation object",', 1, 1); |
199
|
|
|
|
200
|
|
|
$this->setStarredComment('tags={"' . Classes::getClassName($this->generator->objectName) . DefaultInterface::CONTROLLER_POSTFIX |
201
|
|
|
. '"},', 1, 1); |
202
|
|
|
|
203
|
|
|
$this->setParameter([ |
204
|
|
|
'in' => '"path"', |
205
|
|
|
'name' => '"id"', |
206
|
|
|
'required' => 'true', |
207
|
|
|
]); |
208
|
|
|
|
209
|
|
|
$this->setParameter([ |
210
|
|
|
'in' => '"path"', |
211
|
|
|
'name' => '"relations"', |
212
|
|
|
'required' => 'true', |
213
|
|
|
]); |
214
|
|
|
|
215
|
|
|
$this->setResponse([ |
216
|
|
|
'response' => '"' . JSONApiInterface::HTTP_RESPONSE_CODE_NO_CONTENT . '"', |
217
|
|
|
'description' => '"' . self::SUCCESSFUL_OPERATION . '"', |
|
|
|
|
218
|
|
|
]); |
219
|
|
|
|
220
|
|
|
$this->setStarredComment(PhpInterface::CLOSE_PARENTHESES); |
221
|
|
|
|
222
|
|
|
$this->closeComment(); |
223
|
|
|
$this->setNewLines(); |
224
|
|
|
} |
225
|
|
|
} |