@@ 54-126 (lines=73) @@ | ||
51 | * @param integer &$status Variable which contains the HTTP status afterwards |
|
52 | * @return string Content for response body |
|
53 | */ |
|
54 | public function delete( $body, array &$header, &$status ) |
|
55 | { |
|
56 | $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
57 | $context = $this->getContext(); |
|
58 | $view = $this->getView(); |
|
59 | ||
60 | try |
|
61 | { |
|
62 | $view = $this->deleteItems( $view, $body ); |
|
63 | $status = 200; |
|
64 | } |
|
65 | catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
66 | { |
|
67 | $status = $e->getCode(); |
|
68 | $view->errors = array( array( |
|
69 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
70 | 'detail' => $e->getTraceAsString(), |
|
71 | ) ); |
|
72 | } |
|
73 | catch( \Aimeos\MAdmin\Exception $e ) |
|
74 | { |
|
75 | $status = 404; |
|
76 | $view->errors = array( array( |
|
77 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
78 | 'detail' => $e->getTraceAsString(), |
|
79 | ) ); |
|
80 | } |
|
81 | catch( \Aimeos\MShop\Exception $e ) |
|
82 | { |
|
83 | $status = 404; |
|
84 | $view->errors = array( array( |
|
85 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
86 | 'detail' => $e->getTraceAsString(), |
|
87 | ) ); |
|
88 | } |
|
89 | catch( \Exception $e ) |
|
90 | { |
|
91 | $status = 500; |
|
92 | $view->errors = array( array( |
|
93 | 'title' => $e->getMessage(), |
|
94 | 'detail' => $e->getTraceAsString(), |
|
95 | ) ); |
|
96 | } |
|
97 | ||
98 | /** admin/jsonadm/standard/template-delete |
|
99 | * Relative path to the JSON API template for DELETE requests |
|
100 | * |
|
101 | * The template file contains the code and processing instructions |
|
102 | * to generate the result shown in the JSON API body. The |
|
103 | * configuration string is the path to the template file relative |
|
104 | * to the templates directory (usually in admin/jsonadm/templates). |
|
105 | * |
|
106 | * You can overwrite the template file configuration in extensions and |
|
107 | * provide alternative templates. These alternative templates should be |
|
108 | * named like the default one but with the string "standard" replaced by |
|
109 | * an unique name. You may use the name of your project for this. If |
|
110 | * you've implemented an alternative client class as well, "standard" |
|
111 | * should be replaced by the name of the new class. |
|
112 | * |
|
113 | * @param string Relative path to the template creating the body for the DELETE method of the JSON API |
|
114 | * @since 2015.12 |
|
115 | * @category Developer |
|
116 | * @see admin/jsonadm/standard/template-get |
|
117 | * @see admin/jsonadm/standard/template-patch |
|
118 | * @see admin/jsonadm/standard/template-post |
|
119 | * @see admin/jsonadm/standard/template-put |
|
120 | * @see admin/jsonadm/standard/template-options |
|
121 | */ |
|
122 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
|
123 | $default = 'delete-default.php'; |
|
124 | ||
125 | return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | } |
|
127 | ||
128 | ||
129 | /** |
|
@@ 232-304 (lines=73) @@ | ||
229 | * @param integer &$status Variable which contains the HTTP status afterwards |
|
230 | * @return string Content for response body |
|
231 | */ |
|
232 | public function patch( $body, array &$header, &$status ) |
|
233 | { |
|
234 | $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
235 | $context = $this->getContext(); |
|
236 | $view = $this->getView(); |
|
237 | ||
238 | try |
|
239 | { |
|
240 | $view = $this->patchItems( $view, $body, $header ); |
|
241 | $status = 200; |
|
242 | } |
|
243 | catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
244 | { |
|
245 | $status = $e->getCode(); |
|
246 | $view->errors = array( array( |
|
247 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
248 | 'detail' => $e->getTraceAsString(), |
|
249 | ) ); |
|
250 | } |
|
251 | catch( \Aimeos\MAdmin\Exception $e ) |
|
252 | { |
|
253 | $status = 404; |
|
254 | $view->errors = array( array( |
|
255 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
256 | 'detail' => $e->getTraceAsString(), |
|
257 | ) ); |
|
258 | } |
|
259 | catch( \Aimeos\MShop\Exception $e ) |
|
260 | { |
|
261 | $status = 404; |
|
262 | $view->errors = array( array( |
|
263 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
264 | 'detail' => $e->getTraceAsString(), |
|
265 | ) ); |
|
266 | } |
|
267 | catch( \Aimeos\MW\Exception $e ) |
|
268 | { |
|
269 | $status = 500; |
|
270 | $view->errors = array( array( |
|
271 | 'title' => $e->getMessage(), |
|
272 | 'detail' => $e->getTraceAsString(), |
|
273 | ) ); |
|
274 | } |
|
275 | ||
276 | /** admin/jsonadm/standard/template-patch |
|
277 | * Relative path to the JSON API template for PATCH requests |
|
278 | * |
|
279 | * The template file contains the code and processing instructions |
|
280 | * to generate the result shown in the JSON API body. The |
|
281 | * configuration string is the path to the template file relative |
|
282 | * to the templates directory (usually in admin/jsonadm/templates). |
|
283 | * |
|
284 | * You can overwrite the template file configuration in extensions and |
|
285 | * provide alternative templates. These alternative templates should be |
|
286 | * named like the default one but with the string "standard" replaced by |
|
287 | * an unique name. You may use the name of your project for this. If |
|
288 | * you've implemented an alternative client class as well, "standard" |
|
289 | * should be replaced by the name of the new class. |
|
290 | * |
|
291 | * @param string Relative path to the template creating the body for the PATCH method of the JSON API |
|
292 | * @since 2015.12 |
|
293 | * @category Developer |
|
294 | * @see admin/jsonadm/standard/template-get |
|
295 | * @see admin/jsonadm/standard/template-post |
|
296 | * @see admin/jsonadm/standard/template-delete |
|
297 | * @see admin/jsonadm/standard/template-put |
|
298 | * @see admin/jsonadm/standard/template-options |
|
299 | */ |
|
300 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
|
301 | $default = 'patch-default.php'; |
|
302 | ||
303 | return $view->render( $view->config( $tplconf, $default ) ); |
|
304 | } |
|
305 | ||
306 | ||
307 | /** |
|
@@ 315-387 (lines=73) @@ | ||
312 | * @param integer &$status Variable which contains the HTTP status afterwards |
|
313 | * @return string Content for response body |
|
314 | */ |
|
315 | public function post( $body, array &$header, &$status ) |
|
316 | { |
|
317 | $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
318 | $context = $this->getContext(); |
|
319 | $view = $this->getView(); |
|
320 | ||
321 | try |
|
322 | { |
|
323 | $view = $this->postItems( $view, $body, $header ); |
|
324 | $status = 201; |
|
325 | } |
|
326 | catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
327 | { |
|
328 | $status = $e->getCode(); |
|
329 | $view->errors = array( array( |
|
330 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
331 | 'detail' => $e->getTraceAsString(), |
|
332 | ) ); |
|
333 | } |
|
334 | catch( \Aimeos\MAdmin\Exception $e ) |
|
335 | { |
|
336 | $status = 404; |
|
337 | $view->errors = array( array( |
|
338 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
339 | 'detail' => $e->getTraceAsString(), |
|
340 | ) ); |
|
341 | } |
|
342 | catch( \Aimeos\MShop\Exception $e ) |
|
343 | { |
|
344 | $status = 404; |
|
345 | $view->errors = array( array( |
|
346 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
347 | 'detail' => $e->getTraceAsString(), |
|
348 | ) ); |
|
349 | } |
|
350 | catch( \Exception $e ) |
|
351 | { |
|
352 | $status = 500; |
|
353 | $view->errors = array( array( |
|
354 | 'title' => $e->getMessage(), |
|
355 | 'detail' => $e->getTraceAsString(), |
|
356 | ) ); |
|
357 | } |
|
358 | ||
359 | /** admin/jsonadm/standard/template-post |
|
360 | * Relative path to the JSON API template for POST requests |
|
361 | * |
|
362 | * The template file contains the code and processing instructions |
|
363 | * to generate the result shown in the JSON API body. The |
|
364 | * configuration string is the path to the template file relative |
|
365 | * to the templates directory (usually in admin/jsonadm/templates). |
|
366 | * |
|
367 | * You can overwrite the template file configuration in extensions and |
|
368 | * provide alternative templates. These alternative templates should be |
|
369 | * named like the default one but with the string "standard" replaced by |
|
370 | * an unique name. You may use the name of your project for this. If |
|
371 | * you've implemented an alternative client class as well, "standard" |
|
372 | * should be replaced by the name of the new class. |
|
373 | * |
|
374 | * @param string Relative path to the template creating the body for the POST method of the JSON API |
|
375 | * @since 2015.12 |
|
376 | * @category Developer |
|
377 | * @see admin/jsonadm/standard/template-get |
|
378 | * @see admin/jsonadm/standard/template-patch |
|
379 | * @see admin/jsonadm/standard/template-delete |
|
380 | * @see admin/jsonadm/standard/template-put |
|
381 | * @see admin/jsonadm/standard/template-options |
|
382 | */ |
|
383 | $tplconf = 'admin/jsonadm/standard/template-post'; |
|
384 | $default = 'post-default.php'; |
|
385 | ||
386 | return $view->render( $view->config( $tplconf, $default ) ); |
|
387 | } |
|
388 | ||
389 | ||
390 | /** |