aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 21e4552d..2f5923c8 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -47,6 +47,7 @@ class WallabagRestController extends Controller
47 * {"name"="username", "dataType"="string", "required"=true, "description"="username"} 47 * {"name"="username", "dataType"="string", "required"=true, "description"="username"}
48 * } 48 * }
49 * ) 49 * )
50 *
50 * @return array 51 * @return array
51 */ 52 */
52 public function getSaltAction($username) 53 public function getSaltAction($username)
@@ -77,6 +78,7 @@ class WallabagRestController extends Controller
77 * {"name"="tags", "dataType"="string", "required"=false, "format"="api%2Crest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."}, 78 * {"name"="tags", "dataType"="string", "required"=false, "format"="api%2Crest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."},
78 * } 79 * }
79 * ) 80 * )
81 *
80 * @return Entry 82 * @return Entry
81 */ 83 */
82 public function getEntriesAction(Request $request) 84 public function getEntriesAction(Request $request)
@@ -109,13 +111,14 @@ class WallabagRestController extends Controller
109 } 111 }
110 112
111 /** 113 /**
112 * Retrieve a single entry 114 * Retrieve a single entry.
113 * 115 *
114 * @ApiDoc( 116 * @ApiDoc(
115 * requirements={ 117 * requirements={
116 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} 118 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
117 * } 119 * }
118 * ) 120 * )
121 *
119 * @return Entry 122 * @return Entry
120 */ 123 */
121 public function getEntryAction(Entry $entry) 124 public function getEntryAction(Entry $entry)
@@ -128,7 +131,7 @@ class WallabagRestController extends Controller
128 } 131 }
129 132
130 /** 133 /**
131 * Create an entry 134 * Create an entry.
132 * 135 *
133 * @ApiDoc( 136 * @ApiDoc(
134 * parameters={ 137 * parameters={
@@ -137,6 +140,7 @@ class WallabagRestController extends Controller
137 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 140 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
138 * } 141 * }
139 * ) 142 * )
143 *
140 * @return Entry 144 * @return Entry
141 */ 145 */
142 public function postEntriesAction(Request $request) 146 public function postEntriesAction(Request $request)
@@ -164,7 +168,7 @@ class WallabagRestController extends Controller
164 } 168 }
165 169
166 /** 170 /**
167 * Change several properties of an entry 171 * Change several properties of an entry.
168 * 172 *
169 * @ApiDoc( 173 * @ApiDoc(
170 * requirements={ 174 * requirements={
@@ -177,15 +181,16 @@ class WallabagRestController extends Controller
177 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."}, 181 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."},
178 * } 182 * }
179 * ) 183 * )
184 *
180 * @return Entry 185 * @return Entry
181 */ 186 */
182 public function patchEntriesAction(Entry $entry, Request $request) 187 public function patchEntriesAction(Entry $entry, Request $request)
183 { 188 {
184 $this->validateUserAccess($entry->getUser()->getId(), $this->getUser()->getId()); 189 $this->validateUserAccess($entry->getUser()->getId(), $this->getUser()->getId());
185 190
186 $title = $request->request->get("title"); 191 $title = $request->request->get('title');
187 $isArchived = $request->request->get("archive"); 192 $isArchived = $request->request->get('archive');
188 $isStarred = $request->request->get("star"); 193 $isStarred = $request->request->get('star');
189 194
190 if (!is_null($title)) { 195 if (!is_null($title)) {
191 $entry->setTitle($title); 196 $entry->setTitle($title);
@@ -213,13 +218,14 @@ class WallabagRestController extends Controller
213 } 218 }
214 219
215 /** 220 /**
216 * Delete **permanently** an entry 221 * Delete **permanently** an entry.
217 * 222 *
218 * @ApiDoc( 223 * @ApiDoc(
219 * requirements={ 224 * requirements={
220 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} 225 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
221 * } 226 * }
222 * ) 227 * )
228 *
223 * @return Entry 229 * @return Entry
224 */ 230 */
225 public function deleteEntriesAction(Entry $entry) 231 public function deleteEntriesAction(Entry $entry)
@@ -236,7 +242,7 @@ class WallabagRestController extends Controller
236 } 242 }
237 243
238 /** 244 /**
239 * Retrieve all tags for an entry 245 * Retrieve all tags for an entry.
240 * 246 *
241 * @ApiDoc( 247 * @ApiDoc(
242 * requirements={ 248 * requirements={
@@ -254,7 +260,7 @@ class WallabagRestController extends Controller
254 } 260 }
255 261
256 /** 262 /**
257 * Add one or more tags to an entry 263 * Add one or more tags to an entry.
258 * 264 *
259 * @ApiDoc( 265 * @ApiDoc(
260 * requirements={ 266 * requirements={
@@ -284,7 +290,7 @@ class WallabagRestController extends Controller
284 } 290 }
285 291
286 /** 292 /**
287 * Permanently remove one tag for an entry 293 * Permanently remove one tag for an entry.
288 * 294 *
289 * @ApiDoc( 295 * @ApiDoc(
290 * requirements={ 296 * requirements={
@@ -308,7 +314,7 @@ class WallabagRestController extends Controller
308 } 314 }
309 315
310 /** 316 /**
311 * Retrieve all tags 317 * Retrieve all tags.
312 * 318 *
313 * @ApiDoc() 319 * @ApiDoc()
314 */ 320 */
@@ -320,7 +326,7 @@ class WallabagRestController extends Controller
320 } 326 }
321 327
322 /** 328 /**
323 * Permanently remove one tag from **every** entry 329 * Permanently remove one tag from **every** entry.
324 * 330 *
325 * @ApiDoc( 331 * @ApiDoc(
326 * requirements={ 332 * requirements={
@@ -343,10 +349,10 @@ class WallabagRestController extends Controller
343 349
344 /** 350 /**
345 * Validate that the first id is equal to the second one. 351 * Validate that the first id is equal to the second one.
346 * If not, throw exception. It means a user try to access information from an other user 352 * If not, throw exception. It means a user try to access information from an other user.
347 * 353 *
348 * @param integer $requestUserId User id from the requested source 354 * @param int $requestUserId User id from the requested source
349 * @param integer $currentUserId User id from the retrieved source 355 * @param int $currentUserId User id from the retrieved source
350 */ 356 */
351 private function validateUserAccess($requestUserId, $currentUserId) 357 private function validateUserAccess($requestUserId, $currentUserId)
352 { 358 {
@@ -357,7 +363,7 @@ class WallabagRestController extends Controller
357 363
358 /** 364 /**
359 * Send a JSON Response. 365 * Send a JSON Response.
360 * We don't use the Symfony JsonRespone, because it takes an array as parameter instead of a JSON string 366 * We don't use the Symfony JsonRespone, because it takes an array as parameter instead of a JSON string.
361 * 367 *
362 * @param string $json 368 * @param string $json
363 * 369 *