@@ -99,8 +99,7 @@ |
||
99 | 99 | $decorators = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/local', [] ); |
100 | 100 | $client = self::addDecorators( $client, $decorators, $classprefix, $context, $path ); |
101 | 101 | } |
102 | - } |
|
103 | - else |
|
102 | + } else |
|
104 | 103 | { |
105 | 104 | $classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\'; |
106 | 105 | $client = self::addDecorators( $client, $decorators, $classprefix, $context, $path ); |
@@ -39,24 +39,21 @@ discard block |
||
39 | 39 | { |
40 | 40 | $response = $this->deleteItems( $view, $request, $response ); |
41 | 41 | $status = 200; |
42 | - } |
|
43 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
42 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
44 | 43 | { |
45 | 44 | $status = $e->getCode(); |
46 | 45 | $view->errors = array( array( |
47 | 46 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
48 | 47 | 'detail' => $e->getTraceAsString(), |
49 | 48 | ) ); |
50 | - } |
|
51 | - catch( \Aimeos\MShop\Exception $e ) |
|
49 | + } catch( \Aimeos\MShop\Exception $e ) |
|
52 | 50 | { |
53 | 51 | $status = 404; |
54 | 52 | $view->errors = array( array( |
55 | 53 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
56 | 54 | 'detail' => $e->getTraceAsString(), |
57 | 55 | ) ); |
58 | - } |
|
59 | - catch( \Exception $e ) |
|
56 | + } catch( \Exception $e ) |
|
60 | 57 | { |
61 | 58 | $status = 500; |
62 | 59 | $view->errors = array( array( |
@@ -116,16 +113,14 @@ discard block |
||
116 | 113 | { |
117 | 114 | $response = $this->getItems( $view, $request, $response ); |
118 | 115 | $status = 200; |
119 | - } |
|
120 | - catch( \Aimeos\MShop\Exception $e ) |
|
116 | + } catch( \Aimeos\MShop\Exception $e ) |
|
121 | 117 | { |
122 | 118 | $status = 404; |
123 | 119 | $view->errors = array( array( |
124 | 120 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
125 | 121 | 'detail' => $e->getTraceAsString(), |
126 | 122 | ) ); |
127 | - } |
|
128 | - catch( \Exception $e ) |
|
123 | + } catch( \Exception $e ) |
|
129 | 124 | { |
130 | 125 | $status = 500; |
131 | 126 | $view->errors = array( array( |
@@ -163,8 +158,7 @@ discard block |
||
163 | 158 | */ |
164 | 159 | $tplconf = 'admin/jsonadm/standard/template-aggregate'; |
165 | 160 | $default = 'aggregate-standard.php'; |
166 | - } |
|
167 | - else |
|
161 | + } else |
|
168 | 162 | { |
169 | 163 | /** admin/jsonadm/standard/template-get |
170 | 164 | * Relative path to the JSON API template for GET requests |
@@ -218,24 +212,21 @@ discard block |
||
218 | 212 | { |
219 | 213 | $response = $this->patchItems( $view, $request, $response ); |
220 | 214 | $status = 200; |
221 | - } |
|
222 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
215 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
223 | 216 | { |
224 | 217 | $status = $e->getCode(); |
225 | 218 | $view->errors = array( array( |
226 | 219 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
227 | 220 | 'detail' => $e->getTraceAsString(), |
228 | 221 | ) ); |
229 | - } |
|
230 | - catch( \Aimeos\MShop\Exception $e ) |
|
222 | + } catch( \Aimeos\MShop\Exception $e ) |
|
231 | 223 | { |
232 | 224 | $status = 404; |
233 | 225 | $view->errors = array( array( |
234 | 226 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
235 | 227 | 'detail' => $e->getTraceAsString(), |
236 | 228 | ) ); |
237 | - } |
|
238 | - catch( \Exception $e ) |
|
229 | + } catch( \Exception $e ) |
|
239 | 230 | { |
240 | 231 | $status = 500; |
241 | 232 | $view->errors = array( array( |
@@ -295,24 +286,21 @@ discard block |
||
295 | 286 | { |
296 | 287 | $response = $this->postItems( $view, $request, $response ); |
297 | 288 | $status = 201; |
298 | - } |
|
299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
289 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
300 | 290 | { |
301 | 291 | $status = $e->getCode(); |
302 | 292 | $view->errors = array( array( |
303 | 293 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
304 | 294 | 'detail' => $e->getTraceAsString(), |
305 | 295 | ) ); |
306 | - } |
|
307 | - catch( \Aimeos\MShop\Exception $e ) |
|
296 | + } catch( \Aimeos\MShop\Exception $e ) |
|
308 | 297 | { |
309 | 298 | $status = 404; |
310 | 299 | $view->errors = array( array( |
311 | 300 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
312 | 301 | 'detail' => $e->getTraceAsString(), |
313 | 302 | ) ); |
314 | - } |
|
315 | - catch( \Exception $e ) |
|
303 | + } catch( \Exception $e ) |
|
316 | 304 | { |
317 | 305 | $status = 500; |
318 | 306 | $view->errors = array( array( |
@@ -440,16 +428,14 @@ discard block |
||
440 | 428 | $view->attributes = $attributes; |
441 | 429 | |
442 | 430 | $status = 200; |
443 | - } |
|
444 | - catch( \Aimeos\MShop\Exception $e ) |
|
431 | + } catch( \Aimeos\MShop\Exception $e ) |
|
445 | 432 | { |
446 | 433 | $status = 404; |
447 | 434 | $view->errors = array( array( |
448 | 435 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
449 | 436 | 'detail' => $e->getTraceAsString(), |
450 | 437 | ) ); |
451 | - } |
|
452 | - catch( \Exception $e ) |
|
438 | + } catch( \Exception $e ) |
|
453 | 439 | { |
454 | 440 | $status = 500; |
455 | 441 | $view->errors = array( array( |
@@ -519,8 +505,7 @@ discard block |
||
519 | 505 | $ids = $this->getIds( $payload ); |
520 | 506 | $manager->deleteItems( $ids ); |
521 | 507 | $view->total = count( $ids ); |
522 | - } |
|
523 | - else |
|
508 | + } else |
|
524 | 509 | { |
525 | 510 | $manager->deleteItem( $id ); |
526 | 511 | $view->total = 1; |
@@ -558,8 +543,7 @@ discard block |
||
558 | 543 | $view->data = $manager->searchItems( $search, [], $total ); |
559 | 544 | $view->childItems = $this->getChildItems( $view->data, $include ); |
560 | 545 | $view->listItems = $this->getListItems( $view->data, $include ); |
561 | - } |
|
562 | - else |
|
546 | + } else |
|
563 | 547 | { |
564 | 548 | $view->data = $manager->getItem( $id, [] ); |
565 | 549 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -599,16 +583,14 @@ discard block |
||
599 | 583 | $view->data = $data; |
600 | 584 | $view->total = count( $data ); |
601 | 585 | $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
602 | - } |
|
603 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
586 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
604 | 587 | { |
605 | 588 | $payload->data->id = $id; |
606 | 589 | $data = $this->saveEntry( $manager, $payload->data ); |
607 | 590 | |
608 | 591 | $view->data = $data; |
609 | 592 | $view->total = 1; |
610 | - } |
|
611 | - else |
|
593 | + } else |
|
612 | 594 | { |
613 | 595 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
614 | 596 | } |
@@ -647,8 +629,7 @@ discard block |
||
647 | 629 | $view->data = $data; |
648 | 630 | $view->total = count( $data ); |
649 | 631 | $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
650 | - } |
|
651 | - else |
|
632 | + } else |
|
652 | 633 | { |
653 | 634 | $payload->data->id = null; |
654 | 635 | $data = $this->saveEntry( $manager, $payload->data ); |
@@ -59,9 +59,12 @@ |
||
59 | 59 | |
60 | 60 | , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
61 | 61 | |
62 | - <?php else : ?> |
|
62 | + <?php else { |
|
63 | + : ?> |
|
63 | 64 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
65 | + , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); |
|
66 | +} |
|
67 | +?> |
|
65 | 68 | |
66 | 69 | <?php endif; ?> |
67 | 70 | } |