@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$data = $this->get( 'data', array() ); |
|
| 3 | +$data = $this->get('data', array()); |
|
| 4 | 4 | |
| 5 | 5 | ?> |
| 6 | 6 | { |
| 7 | 7 | "meta": { |
| 8 | - "total": <?php echo count( $data ); ?> |
|
| 8 | + "total": <?php echo count($data); ?> |
|
| 9 | 9 | |
| 10 | 10 | }, |
| 11 | -<?php if( isset( $this->errors ) ) : ?> |
|
| 12 | - "errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
| 13 | -<?php elseif( isset( $this->data ) ) : ?> |
|
| 11 | +<?php if (isset($this->errors)) : ?> |
|
| 12 | + "errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
| 13 | +<?php elseif (isset($this->data)) : ?> |
|
| 14 | 14 | "data": [ |
| 15 | -<?php foreach( $data as $key => $value ) : ?> |
|
| 16 | -<?php echo json_encode( array( 'id' => $key, 'type' => 'aggregate', 'attributes' => $value ) ); ?> |
|
| 15 | +<?php foreach ($data as $key => $value) : ?> |
|
| 16 | +<?php echo json_encode(array('id' => $key, 'type' => 'aggregate', 'attributes' => $value)); ?> |
|
| 17 | 17 | <?php endforeach; ?> |
| 18 | 18 | ] |
| 19 | 19 | <?php endif; ?> |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Order\Standard( $this->context, $this->view, $templatePaths, 'order' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Order\Standard($this->context, $this->view, $templatePaths, 'order'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,25 +30,25 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'order.editor' => 'core:unittest' ) |
|
| 33 | + '==' => array('order.editor' => 'core:unittest') |
|
| 34 | 34 | ), |
| 35 | 35 | 'aggregate' => 'order.cdate', |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | 40 | $header = array(); |
| 41 | 41 | $status = 500; |
| 42 | 42 | |
| 43 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 44 | 44 | |
| 45 | - $this->assertEquals( 200, $status ); |
|
| 46 | - $this->assertEquals( 1, count( $header ) ); |
|
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'aggregate', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertGreaterThan( 0, count( $result['data'][0]['attributes'] ) ); |
|
| 51 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 45 | + $this->assertEquals(200, $status); |
|
| 46 | + $this->assertEquals(1, count($header)); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('aggregate', $result['data'][0]['type']); |
|
| 50 | + $this->assertGreaterThan(0, count($result['data'][0]['attributes'])); |
|
| 51 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -56,27 +56,27 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $params = array( |
| 58 | 58 | 'filter' => array( |
| 59 | - '==' => array( 'order.datepayment' => '2008-02-15 12:34:56' ) |
|
| 59 | + '==' => array('order.datepayment' => '2008-02-15 12:34:56') |
|
| 60 | 60 | ), |
| 61 | 61 | 'include' => 'order/base,order/status' |
| 62 | 62 | ); |
| 63 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 64 | - $this->view->addHelper( 'param', $helper ); |
|
| 63 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 64 | + $this->view->addHelper('param', $helper); |
|
| 65 | 65 | |
| 66 | 66 | $header = array(); |
| 67 | 67 | $status = 500; |
| 68 | 68 | |
| 69 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 70 | - |
|
| 71 | - $this->assertEquals( 200, $status ); |
|
| 72 | - $this->assertEquals( 1, count( $header ) ); |
|
| 73 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 74 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 75 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
| 76 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
| 77 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base'] ) ); |
|
| 78 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
| 79 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 69 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 70 | + |
|
| 71 | + $this->assertEquals(200, $status); |
|
| 72 | + $this->assertEquals(1, count($header)); |
|
| 73 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 74 | + $this->assertEquals(1, count($result['data'])); |
|
| 75 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
| 76 | + $this->assertEquals(3, count($result['data'][0]['relationships']['order/status'])); |
|
| 77 | + $this->assertEquals(1, count($result['data'][0]['relationships']['order/base'])); |
|
| 78 | + $this->assertEquals(4, count($result['included'])); |
|
| 79 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | 'sort' => 'order.id', |
| 90 | 90 | 'include' => 'order/status' |
| 91 | 91 | ); |
| 92 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 93 | - $this->view->addHelper( 'param', $helper ); |
|
| 92 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 93 | + $this->view->addHelper('param', $helper); |
|
| 94 | 94 | |
| 95 | 95 | $header = array(); |
| 96 | 96 | $status = 500; |
| 97 | 97 | |
| 98 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 99 | - |
|
| 100 | - $this->assertEquals( 200, $status ); |
|
| 101 | - $this->assertEquals( 1, count( $header ) ); |
|
| 102 | - $this->assertGreaterThanOrEqual( 4, $result['meta']['total'] ); |
|
| 103 | - $this->assertGreaterThanOrEqual( 4, count( $result['data'] ) ); |
|
| 104 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
| 105 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 106 | - $this->assertGreaterThanOrEqual( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
| 107 | - $this->assertGreaterThanOrEqual( 11, count( $result['included'] ) ); |
|
| 108 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 98 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 99 | + |
|
| 100 | + $this->assertEquals(200, $status); |
|
| 101 | + $this->assertEquals(1, count($header)); |
|
| 102 | + $this->assertGreaterThanOrEqual(4, $result['meta']['total']); |
|
| 103 | + $this->assertGreaterThanOrEqual(4, count($result['data'])); |
|
| 104 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
| 105 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 106 | + $this->assertGreaterThanOrEqual(3, count($result['data'][0]['relationships']['order/status'])); |
|
| 107 | + $this->assertGreaterThanOrEqual(11, count($result['included'])); |
|
| 108 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 109 | 109 | } |
| 110 | 110 | } |
@@ -29,39 +29,39 @@ discard block |
||
| 29 | 29 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 30 | 30 | * @return string Content for response body |
| 31 | 31 | */ |
| 32 | - public function delete( $body, array &$header, &$status ) |
|
| 32 | + public function delete($body, array &$header, &$status) |
|
| 33 | 33 | { |
| 34 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 34 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 35 | 35 | $view = $this->getView(); |
| 36 | 36 | |
| 37 | 37 | try |
| 38 | 38 | { |
| 39 | - $view = $this->deleteItems( $view, $body ); |
|
| 39 | + $view = $this->deleteItems($view, $body); |
|
| 40 | 40 | $status = 200; |
| 41 | 41 | } |
| 42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 42 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 43 | 43 | { |
| 44 | 44 | $status = $e->getCode(); |
| 45 | - $view->errors = array( array( |
|
| 46 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 45 | + $view->errors = array(array( |
|
| 46 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 47 | 47 | 'detail' => $e->getTraceAsString(), |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | } |
| 50 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 50 | + catch (\Aimeos\MShop\Exception $e) |
|
| 51 | 51 | { |
| 52 | 52 | $status = 404; |
| 53 | - $view->errors = array( array( |
|
| 54 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 53 | + $view->errors = array(array( |
|
| 54 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 55 | 55 | 'detail' => $e->getTraceAsString(), |
| 56 | - ) ); |
|
| 56 | + )); |
|
| 57 | 57 | } |
| 58 | - catch( \Exception $e ) |
|
| 58 | + catch (\Exception $e) |
|
| 59 | 59 | { |
| 60 | 60 | $status = 500; |
| 61 | - $view->errors = array( array( |
|
| 61 | + $view->errors = array(array( |
|
| 62 | 62 | 'title' => $e->getMessage(), |
| 63 | 63 | 'detail' => $e->getTraceAsString(), |
| 64 | - ) ); |
|
| 64 | + )); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** admin/jsonadm/standard/template-delete |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
| 93 | 93 | $default = 'delete-default.php'; |
| 94 | 94 | |
| 95 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 95 | + return $view->render($view->config($tplconf, $default)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
@@ -104,41 +104,41 @@ discard block |
||
| 104 | 104 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 105 | 105 | * @return string Content for response body |
| 106 | 106 | */ |
| 107 | - public function get( $body, array &$header, &$status ) |
|
| 107 | + public function get($body, array &$header, &$status) |
|
| 108 | 108 | { |
| 109 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 109 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 110 | 110 | |
| 111 | 111 | $view = $this->getView(); |
| 112 | - $aggregate = $view->param( 'aggregate' ); |
|
| 112 | + $aggregate = $view->param('aggregate'); |
|
| 113 | 113 | |
| 114 | 114 | try |
| 115 | 115 | { |
| 116 | - if( $aggregate !== null ) { |
|
| 117 | - $view = $this->getAggregate( $view ); |
|
| 116 | + if ($aggregate !== null) { |
|
| 117 | + $view = $this->getAggregate($view); |
|
| 118 | 118 | } else { |
| 119 | - $view = $this->getItems( $view ); |
|
| 119 | + $view = $this->getItems($view); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $status = 200; |
| 123 | 123 | } |
| 124 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 124 | + catch (\Aimeos\MShop\Exception $e) |
|
| 125 | 125 | { |
| 126 | 126 | $status = 404; |
| 127 | - $view->errors = array( array( |
|
| 128 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 127 | + $view->errors = array(array( |
|
| 128 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 129 | 129 | 'detail' => $e->getTraceAsString(), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | } |
| 132 | - catch( \Exception $e ) |
|
| 132 | + catch (\Exception $e) |
|
| 133 | 133 | { |
| 134 | 134 | $status = 500; |
| 135 | - $view->errors = array( array( |
|
| 135 | + $view->errors = array(array( |
|
| 136 | 136 | 'title' => $e->getMessage(), |
| 137 | 137 | 'detail' => $e->getTraceAsString(), |
| 138 | - ) ); |
|
| 138 | + )); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if( $aggregate !== null ) |
|
| 141 | + if ($aggregate !== null) |
|
| 142 | 142 | { |
| 143 | 143 | /** admin/jsonadm/standard/template-aggregate |
| 144 | 144 | * Relative path to the JSON API template for GET aggregate requests |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $default = 'get-default.php'; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 202 | + return $view->render($view->config($tplconf, $default)); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | |
@@ -211,39 +211,39 @@ discard block |
||
| 211 | 211 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 212 | 212 | * @return string Content for response body |
| 213 | 213 | */ |
| 214 | - public function patch( $body, array &$header, &$status ) |
|
| 214 | + public function patch($body, array &$header, &$status) |
|
| 215 | 215 | { |
| 216 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 216 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 217 | 217 | $view = $this->getView(); |
| 218 | 218 | |
| 219 | 219 | try |
| 220 | 220 | { |
| 221 | - $view = $this->patchItems( $view, $body, $header ); |
|
| 221 | + $view = $this->patchItems($view, $body, $header); |
|
| 222 | 222 | $status = 200; |
| 223 | 223 | } |
| 224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 224 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 225 | 225 | { |
| 226 | 226 | $status = $e->getCode(); |
| 227 | - $view->errors = array( array( |
|
| 228 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 227 | + $view->errors = array(array( |
|
| 228 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 229 | 229 | 'detail' => $e->getTraceAsString(), |
| 230 | - ) ); |
|
| 230 | + )); |
|
| 231 | 231 | } |
| 232 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 232 | + catch (\Aimeos\MShop\Exception $e) |
|
| 233 | 233 | { |
| 234 | 234 | $status = 404; |
| 235 | - $view->errors = array( array( |
|
| 236 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 235 | + $view->errors = array(array( |
|
| 236 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 237 | 237 | 'detail' => $e->getTraceAsString(), |
| 238 | - ) ); |
|
| 238 | + )); |
|
| 239 | 239 | } |
| 240 | - catch( \Exception $e ) |
|
| 240 | + catch (\Exception $e) |
|
| 241 | 241 | { |
| 242 | 242 | $status = 500; |
| 243 | - $view->errors = array( array( |
|
| 243 | + $view->errors = array(array( |
|
| 244 | 244 | 'title' => $e->getMessage(), |
| 245 | 245 | 'detail' => $e->getTraceAsString(), |
| 246 | - ) ); |
|
| 246 | + )); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** admin/jsonadm/standard/template-patch |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
| 275 | 275 | $default = 'patch-default.php'; |
| 276 | 276 | |
| 277 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 277 | + return $view->render($view->config($tplconf, $default)); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
@@ -286,39 +286,39 @@ discard block |
||
| 286 | 286 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 287 | 287 | * @return string Content for response body |
| 288 | 288 | */ |
| 289 | - public function post( $body, array &$header, &$status ) |
|
| 289 | + public function post($body, array &$header, &$status) |
|
| 290 | 290 | { |
| 291 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 291 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 292 | 292 | $view = $this->getView(); |
| 293 | 293 | |
| 294 | 294 | try |
| 295 | 295 | { |
| 296 | - $view = $this->postItems( $view, $body, $header ); |
|
| 296 | + $view = $this->postItems($view, $body, $header); |
|
| 297 | 297 | $status = 201; |
| 298 | 298 | } |
| 299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 299 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 300 | 300 | { |
| 301 | 301 | $status = $e->getCode(); |
| 302 | - $view->errors = array( array( |
|
| 303 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 302 | + $view->errors = array(array( |
|
| 303 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 304 | 304 | 'detail' => $e->getTraceAsString(), |
| 305 | - ) ); |
|
| 305 | + )); |
|
| 306 | 306 | } |
| 307 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 307 | + catch (\Aimeos\MShop\Exception $e) |
|
| 308 | 308 | { |
| 309 | 309 | $status = 404; |
| 310 | - $view->errors = array( array( |
|
| 311 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 310 | + $view->errors = array(array( |
|
| 311 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 312 | 312 | 'detail' => $e->getTraceAsString(), |
| 313 | - ) ); |
|
| 313 | + )); |
|
| 314 | 314 | } |
| 315 | - catch( \Exception $e ) |
|
| 315 | + catch (\Exception $e) |
|
| 316 | 316 | { |
| 317 | 317 | $status = 500; |
| 318 | - $view->errors = array( array( |
|
| 318 | + $view->errors = array(array( |
|
| 319 | 319 | 'title' => $e->getMessage(), |
| 320 | 320 | 'detail' => $e->getTraceAsString(), |
| 321 | - ) ); |
|
| 321 | + )); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** admin/jsonadm/standard/template-post |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $tplconf = 'admin/jsonadm/standard/template-post'; |
| 350 | 350 | $default = 'post-default.php'; |
| 351 | 351 | |
| 352 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 352 | + return $view->render($view->config($tplconf, $default)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -361,15 +361,15 @@ discard block |
||
| 361 | 361 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 362 | 362 | * @return string Content for response body |
| 363 | 363 | */ |
| 364 | - public function put( $body, array &$header, &$status ) |
|
| 364 | + public function put($body, array &$header, &$status) |
|
| 365 | 365 | { |
| 366 | 366 | $status = 501; |
| 367 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 367 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 368 | 368 | $view = $this->getView(); |
| 369 | 369 | |
| 370 | - $view->errors = array( array( |
|
| 371 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
| 372 | - ) ); |
|
| 370 | + $view->errors = array(array( |
|
| 371 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
| 372 | + )); |
|
| 373 | 373 | |
| 374 | 374 | /** admin/jsonadm/standard/template-put |
| 375 | 375 | * Relative path to the JSON API template for PUT requests |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $tplconf = 'admin/jsonadm/standard/template-put'; |
| 400 | 400 | $default = 'put-default.php'; |
| 401 | 401 | |
| 402 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 402 | + return $view->render($view->config($tplconf, $default)); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 412 | 412 | * @return string Content for response body |
| 413 | 413 | */ |
| 414 | - public function options( $body, array &$header, &$status ) |
|
| 414 | + public function options($body, array &$header, &$status) |
|
| 415 | 415 | { |
| 416 | 416 | $context = $this->getContext(); |
| 417 | 417 | $view = $this->getView(); |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | { |
| 421 | 421 | $resources = $attributes = array(); |
| 422 | 422 | |
| 423 | - foreach( $this->getDomains( $view ) as $domain ) |
|
| 423 | + foreach ($this->getDomains($view) as $domain) |
|
| 424 | 424 | { |
| 425 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 426 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
| 427 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
| 425 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 426 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
| 427 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $view->resources = $resources; |
@@ -436,21 +436,21 @@ discard block |
||
| 436 | 436 | ); |
| 437 | 437 | $status = 200; |
| 438 | 438 | } |
| 439 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 439 | + catch (\Aimeos\MShop\Exception $e) |
|
| 440 | 440 | { |
| 441 | 441 | $status = 404; |
| 442 | - $view->errors = array( array( |
|
| 443 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 442 | + $view->errors = array(array( |
|
| 443 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 444 | 444 | 'detail' => $e->getTraceAsString(), |
| 445 | - ) ); |
|
| 445 | + )); |
|
| 446 | 446 | } |
| 447 | - catch( \Exception $e ) |
|
| 447 | + catch (\Exception $e) |
|
| 448 | 448 | { |
| 449 | 449 | $status = 500; |
| 450 | - $view->errors = array( array( |
|
| 450 | + $view->errors = array(array( |
|
| 451 | 451 | 'title' => $e->getMessage(), |
| 452 | 452 | 'detail' => $e->getTraceAsString(), |
| 453 | - ) ); |
|
| 453 | + )); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** admin/jsonadm/standard/template-options |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $tplconf = 'admin/jsonadm/standard/template-options'; |
| 482 | 482 | $default = 'options-default.php'; |
| 483 | 483 | |
| 484 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 484 | + return $view->render($view->config($tplconf, $default)); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
@@ -493,23 +493,23 @@ discard block |
||
| 493 | 493 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
| 494 | 494 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
| 495 | 495 | */ |
| 496 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
| 496 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
| 497 | 497 | { |
| 498 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 498 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 499 | 499 | |
| 500 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 500 | + if (($id = $view->param('id')) == null) |
|
| 501 | 501 | { |
| 502 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
| 503 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 502 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
| 503 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $ids = $this->getIds( $request ); |
|
| 507 | - $manager->deleteItems( $ids ); |
|
| 508 | - $view->total = count( $ids ); |
|
| 506 | + $ids = $this->getIds($request); |
|
| 507 | + $manager->deleteItems($ids); |
|
| 508 | + $view->total = count($ids); |
|
| 509 | 509 | } |
| 510 | 510 | else |
| 511 | 511 | { |
| 512 | - $manager->deleteItem( $id ); |
|
| 512 | + $manager->deleteItem($id); |
|
| 513 | 513 | $view->total = 1; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | * @param \Aimeos\MW\View\Iface $view View instance |
| 524 | 524 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 525 | 525 | */ |
| 526 | - protected function getAggregate( \Aimeos\MW\View\Iface $view ) |
|
| 526 | + protected function getAggregate(\Aimeos\MW\View\Iface $view) |
|
| 527 | 527 | { |
| 528 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 528 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 529 | 529 | |
| 530 | - $key = $view->param( 'aggregate' ); |
|
| 530 | + $key = $view->param('aggregate'); |
|
| 531 | 531 | |
| 532 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 533 | - $view->data = $manager->aggregate( $search, $key ); |
|
| 532 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 533 | + $view->data = $manager->aggregate($search, $key); |
|
| 534 | 534 | |
| 535 | 535 | return $view; |
| 536 | 536 | } |
@@ -542,27 +542,27 @@ discard block |
||
| 542 | 542 | * @param \Aimeos\MW\View\Iface $view View instance |
| 543 | 543 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 544 | 544 | */ |
| 545 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
| 545 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
| 546 | 546 | { |
| 547 | 547 | $total = 1; |
| 548 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 549 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 548 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 549 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 550 | 550 | |
| 551 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 551 | + if (($id = $view->param('id')) == null) |
|
| 552 | 552 | { |
| 553 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 554 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 555 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 556 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 553 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 554 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 555 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 556 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 557 | 557 | } |
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | - $view->data = $manager->getItem( $id, array() ); |
|
| 561 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
| 562 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 560 | + $view->data = $manager->getItem($id, array()); |
|
| 561 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
| 562 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 565 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 566 | 566 | $view->total = $total; |
| 567 | 567 | |
| 568 | 568 | return $view; |
@@ -576,9 +576,9 @@ discard block |
||
| 576 | 576 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 577 | 577 | * @deprecated 2016.06 Use getItems() instead |
| 578 | 578 | */ |
| 579 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
| 579 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
| 580 | 580 | { |
| 581 | - return $this->getItems( $view ); |
|
| 581 | + return $this->getItems($view); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -590,33 +590,33 @@ discard block |
||
| 590 | 590 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
| 591 | 591 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 592 | 592 | */ |
| 593 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 593 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 594 | 594 | { |
| 595 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 596 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 595 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 596 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 599 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 600 | 600 | |
| 601 | - if( is_array( $request->data ) ) |
|
| 601 | + if (is_array($request->data)) |
|
| 602 | 602 | { |
| 603 | - $data = $this->saveData( $manager, $request ); |
|
| 603 | + $data = $this->saveData($manager, $request); |
|
| 604 | 604 | |
| 605 | 605 | $view->data = $data; |
| 606 | - $view->total = count( $data ); |
|
| 606 | + $view->total = count($data); |
|
| 607 | 607 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 608 | 608 | } |
| 609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 609 | + elseif (($id = $view->param('id')) != null) |
|
| 610 | 610 | { |
| 611 | 611 | $request->data->id = $id; |
| 612 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 612 | + $data = $this->saveEntry($manager, $request->data); |
|
| 613 | 613 | |
| 614 | 614 | $view->data = $data; |
| 615 | 615 | $view->total = 1; |
| 616 | 616 | } |
| 617 | 617 | else |
| 618 | 618 | { |
| 619 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
| 619 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | return $view; |
@@ -631,31 +631,31 @@ discard block |
||
| 631 | 631 | * @param array &$header Associative list of HTTP headers as value/result parameter |
| 632 | 632 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 633 | 633 | */ |
| 634 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 634 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 635 | 635 | { |
| 636 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 637 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 636 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 637 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
| 641 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
| 640 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
| 641 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| 645 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 645 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 646 | 646 | |
| 647 | - if( is_array( $request->data ) ) |
|
| 647 | + if (is_array($request->data)) |
|
| 648 | 648 | { |
| 649 | - $data = $this->saveData( $manager, $request ); |
|
| 649 | + $data = $this->saveData($manager, $request); |
|
| 650 | 650 | |
| 651 | 651 | $view->data = $data; |
| 652 | - $view->total = count( $data ); |
|
| 652 | + $view->total = count($data); |
|
| 653 | 653 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 654 | 654 | } |
| 655 | 655 | else |
| 656 | 656 | { |
| 657 | 657 | $request->data->id = null; |
| 658 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 658 | + $data = $this->saveEntry($manager, $request->data); |
|
| 659 | 659 | |
| 660 | 660 | $view->data = $data; |
| 661 | 661 | $view->total = 1; |
@@ -38,24 +38,21 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $view = $this->deleteItems( $view, $body ); |
| 40 | 40 | $status = 200; |
| 41 | - } |
|
| 42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 41 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 43 | 42 | { |
| 44 | 43 | $status = $e->getCode(); |
| 45 | 44 | $view->errors = array( array( |
| 46 | 45 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 47 | 46 | 'detail' => $e->getTraceAsString(), |
| 48 | 47 | ) ); |
| 49 | - } |
|
| 50 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 48 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 51 | 49 | { |
| 52 | 50 | $status = 404; |
| 53 | 51 | $view->errors = array( array( |
| 54 | 52 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 55 | 53 | 'detail' => $e->getTraceAsString(), |
| 56 | 54 | ) ); |
| 57 | - } |
|
| 58 | - catch( \Exception $e ) |
|
| 55 | + } catch( \Exception $e ) |
|
| 59 | 56 | { |
| 60 | 57 | $status = 500; |
| 61 | 58 | $view->errors = array( array( |
@@ -120,16 +117,14 @@ discard block |
||
| 120 | 117 | } |
| 121 | 118 | |
| 122 | 119 | $status = 200; |
| 123 | - } |
|
| 124 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 120 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 125 | 121 | { |
| 126 | 122 | $status = 404; |
| 127 | 123 | $view->errors = array( array( |
| 128 | 124 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 129 | 125 | 'detail' => $e->getTraceAsString(), |
| 130 | 126 | ) ); |
| 131 | - } |
|
| 132 | - catch( \Exception $e ) |
|
| 127 | + } catch( \Exception $e ) |
|
| 133 | 128 | { |
| 134 | 129 | $status = 500; |
| 135 | 130 | $view->errors = array( array( |
@@ -167,8 +162,7 @@ discard block |
||
| 167 | 162 | */ |
| 168 | 163 | $tplconf = 'admin/jsonadm/standard/template-aggregate'; |
| 169 | 164 | $default = 'aggregate-default.php'; |
| 170 | - } |
|
| 171 | - else |
|
| 165 | + } else |
|
| 172 | 166 | { |
| 173 | 167 | /** admin/jsonadm/standard/template-get |
| 174 | 168 | * Relative path to the JSON API template for GET requests |
@@ -220,24 +214,21 @@ discard block |
||
| 220 | 214 | { |
| 221 | 215 | $view = $this->patchItems( $view, $body, $header ); |
| 222 | 216 | $status = 200; |
| 223 | - } |
|
| 224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 217 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 225 | 218 | { |
| 226 | 219 | $status = $e->getCode(); |
| 227 | 220 | $view->errors = array( array( |
| 228 | 221 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 229 | 222 | 'detail' => $e->getTraceAsString(), |
| 230 | 223 | ) ); |
| 231 | - } |
|
| 232 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 224 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 233 | 225 | { |
| 234 | 226 | $status = 404; |
| 235 | 227 | $view->errors = array( array( |
| 236 | 228 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 237 | 229 | 'detail' => $e->getTraceAsString(), |
| 238 | 230 | ) ); |
| 239 | - } |
|
| 240 | - catch( \Exception $e ) |
|
| 231 | + } catch( \Exception $e ) |
|
| 241 | 232 | { |
| 242 | 233 | $status = 500; |
| 243 | 234 | $view->errors = array( array( |
@@ -295,24 +286,21 @@ discard block |
||
| 295 | 286 | { |
| 296 | 287 | $view = $this->postItems( $view, $body, $header ); |
| 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( |
@@ -435,16 +423,14 @@ discard block |
||
| 435 | 423 | 'Allow' => 'DELETE,GET,PATCH,POST,OPTIONS' |
| 436 | 424 | ); |
| 437 | 425 | $status = 200; |
| 438 | - } |
|
| 439 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 426 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 440 | 427 | { |
| 441 | 428 | $status = 404; |
| 442 | 429 | $view->errors = array( array( |
| 443 | 430 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 444 | 431 | 'detail' => $e->getTraceAsString(), |
| 445 | 432 | ) ); |
| 446 | - } |
|
| 447 | - catch( \Exception $e ) |
|
| 433 | + } catch( \Exception $e ) |
|
| 448 | 434 | { |
| 449 | 435 | $status = 500; |
| 450 | 436 | $view->errors = array( array( |
@@ -506,8 +492,7 @@ discard block |
||
| 506 | 492 | $ids = $this->getIds( $request ); |
| 507 | 493 | $manager->deleteItems( $ids ); |
| 508 | 494 | $view->total = count( $ids ); |
| 509 | - } |
|
| 510 | - else |
|
| 495 | + } else |
|
| 511 | 496 | { |
| 512 | 497 | $manager->deleteItem( $id ); |
| 513 | 498 | $view->total = 1; |
@@ -554,8 +539,7 @@ discard block |
||
| 554 | 539 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 555 | 540 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 556 | 541 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 557 | - } |
|
| 558 | - else |
|
| 542 | + } else |
|
| 559 | 543 | { |
| 560 | 544 | $view->data = $manager->getItem( $id, array() ); |
| 561 | 545 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -605,16 +589,14 @@ discard block |
||
| 605 | 589 | $view->data = $data; |
| 606 | 590 | $view->total = count( $data ); |
| 607 | 591 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 608 | - } |
|
| 609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 592 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 610 | 593 | { |
| 611 | 594 | $request->data->id = $id; |
| 612 | 595 | $data = $this->saveEntry( $manager, $request->data ); |
| 613 | 596 | |
| 614 | 597 | $view->data = $data; |
| 615 | 598 | $view->total = 1; |
| 616 | - } |
|
| 617 | - else |
|
| 599 | + } else |
|
| 618 | 600 | { |
| 619 | 601 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
| 620 | 602 | } |
@@ -651,8 +633,7 @@ discard block |
||
| 651 | 633 | $view->data = $data; |
| 652 | 634 | $view->total = count( $data ); |
| 653 | 635 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 654 | - } |
|
| 655 | - else |
|
| 636 | + } else |
|
| 656 | 637 | { |
| 657 | 638 | $request->data->id = null; |
| 658 | 639 | $data = $this->saveEntry( $manager, $request->data ); |