@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
| 34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
| 35 | 35 | */ |
| 36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
| 36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
| 37 | 37 | { |
| 38 | 38 | $this->view = $view; |
| 39 | 39 | $this->context = $context; |
@@ -50,39 +50,39 @@ discard block |
||
| 50 | 50 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 51 | 51 | * @return string Content for response body |
| 52 | 52 | */ |
| 53 | - public function delete( $body, array &$header, &$status ) |
|
| 53 | + public function delete($body, array &$header, &$status) |
|
| 54 | 54 | { |
| 55 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 55 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 56 | 56 | $view = $this->getView(); |
| 57 | 57 | |
| 58 | 58 | try |
| 59 | 59 | { |
| 60 | - $view = $this->deleteItems( $view, $body ); |
|
| 60 | + $view = $this->deleteItems($view, $body); |
|
| 61 | 61 | $status = 200; |
| 62 | 62 | } |
| 63 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 63 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 64 | 64 | { |
| 65 | 65 | $status = $e->getCode(); |
| 66 | - $view->errors = array( array( |
|
| 67 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 66 | + $view->errors = array(array( |
|
| 67 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 68 | 68 | 'detail' => $e->getTraceAsString(), |
| 69 | - ) ); |
|
| 69 | + )); |
|
| 70 | 70 | } |
| 71 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 71 | + catch (\Aimeos\MShop\Exception $e) |
|
| 72 | 72 | { |
| 73 | 73 | $status = 404; |
| 74 | - $view->errors = array( array( |
|
| 75 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 74 | + $view->errors = array(array( |
|
| 75 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 76 | 76 | 'detail' => $e->getTraceAsString(), |
| 77 | - ) ); |
|
| 77 | + )); |
|
| 78 | 78 | } |
| 79 | - catch( \Exception $e ) |
|
| 79 | + catch (\Exception $e) |
|
| 80 | 80 | { |
| 81 | 81 | $status = 500; |
| 82 | - $view->errors = array( array( |
|
| 82 | + $view->errors = array(array( |
|
| 83 | 83 | 'title' => $e->getMessage(), |
| 84 | 84 | 'detail' => $e->getTraceAsString(), |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** admin/jsonadm/standard/template-delete |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
| 113 | 113 | $default = 'delete-default.php'; |
| 114 | 114 | |
| 115 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 115 | + return $view->render($view->config($tplconf, $default)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
@@ -124,31 +124,31 @@ discard block |
||
| 124 | 124 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 125 | 125 | * @return string Content for response body |
| 126 | 126 | */ |
| 127 | - public function get( $body, array &$header, &$status ) |
|
| 127 | + public function get($body, array &$header, &$status) |
|
| 128 | 128 | { |
| 129 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 129 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 130 | 130 | $view = $this->getView(); |
| 131 | 131 | |
| 132 | 132 | try |
| 133 | 133 | { |
| 134 | - $view = $this->getItem( $view ); |
|
| 134 | + $view = $this->getItem($view); |
|
| 135 | 135 | $status = 200; |
| 136 | 136 | } |
| 137 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 137 | + catch (\Aimeos\MShop\Exception $e) |
|
| 138 | 138 | { |
| 139 | 139 | $status = 404; |
| 140 | - $view->errors = array( array( |
|
| 141 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 140 | + $view->errors = array(array( |
|
| 141 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 142 | 142 | 'detail' => $e->getTraceAsString(), |
| 143 | - ) ); |
|
| 143 | + )); |
|
| 144 | 144 | } |
| 145 | - catch( \Exception $e ) |
|
| 145 | + catch (\Exception $e) |
|
| 146 | 146 | { |
| 147 | 147 | $status = 500; |
| 148 | - $view->errors = array( array( |
|
| 148 | + $view->errors = array(array( |
|
| 149 | 149 | 'title' => $e->getMessage(), |
| 150 | 150 | 'detail' => $e->getTraceAsString(), |
| 151 | - ) ); |
|
| 151 | + )); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** admin/jsonadm/standard/template-get |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $tplconf = 'admin/jsonadm/standard/template-get'; |
| 179 | 179 | $default = 'get-default.php'; |
| 180 | 180 | |
| 181 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 181 | + return $view->render($view->config($tplconf, $default)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -190,39 +190,39 @@ discard block |
||
| 190 | 190 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 191 | 191 | * @return string Content for response body |
| 192 | 192 | */ |
| 193 | - public function patch( $body, array &$header, &$status ) |
|
| 193 | + public function patch($body, array &$header, &$status) |
|
| 194 | 194 | { |
| 195 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 195 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 196 | 196 | $view = $this->getView(); |
| 197 | 197 | |
| 198 | 198 | try |
| 199 | 199 | { |
| 200 | - $view = $this->patchItems( $view, $body, $header ); |
|
| 200 | + $view = $this->patchItems($view, $body, $header); |
|
| 201 | 201 | $status = 200; |
| 202 | 202 | } |
| 203 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 203 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 204 | 204 | { |
| 205 | 205 | $status = $e->getCode(); |
| 206 | - $view->errors = array( array( |
|
| 207 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 206 | + $view->errors = array(array( |
|
| 207 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 208 | 208 | 'detail' => $e->getTraceAsString(), |
| 209 | - ) ); |
|
| 209 | + )); |
|
| 210 | 210 | } |
| 211 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 211 | + catch (\Aimeos\MShop\Exception $e) |
|
| 212 | 212 | { |
| 213 | 213 | $status = 404; |
| 214 | - $view->errors = array( array( |
|
| 215 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 214 | + $view->errors = array(array( |
|
| 215 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 216 | 216 | 'detail' => $e->getTraceAsString(), |
| 217 | - ) ); |
|
| 217 | + )); |
|
| 218 | 218 | } |
| 219 | - catch( \Exception $e ) |
|
| 219 | + catch (\Exception $e) |
|
| 220 | 220 | { |
| 221 | 221 | $status = 500; |
| 222 | - $view->errors = array( array( |
|
| 222 | + $view->errors = array(array( |
|
| 223 | 223 | 'title' => $e->getMessage(), |
| 224 | 224 | 'detail' => $e->getTraceAsString(), |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** admin/jsonadm/standard/template-patch |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
| 253 | 253 | $default = 'patch-default.php'; |
| 254 | 254 | |
| 255 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 255 | + return $view->render($view->config($tplconf, $default)); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -264,39 +264,39 @@ discard block |
||
| 264 | 264 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 265 | 265 | * @return string Content for response body |
| 266 | 266 | */ |
| 267 | - public function post( $body, array &$header, &$status ) |
|
| 267 | + public function post($body, array &$header, &$status) |
|
| 268 | 268 | { |
| 269 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 269 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 270 | 270 | $view = $this->getView(); |
| 271 | 271 | |
| 272 | 272 | try |
| 273 | 273 | { |
| 274 | - $view = $this->postItems( $view, $body, $header ); |
|
| 274 | + $view = $this->postItems($view, $body, $header); |
|
| 275 | 275 | $status = 201; |
| 276 | 276 | } |
| 277 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 277 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 278 | 278 | { |
| 279 | 279 | $status = $e->getCode(); |
| 280 | - $view->errors = array( array( |
|
| 281 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 280 | + $view->errors = array(array( |
|
| 281 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 282 | 282 | 'detail' => $e->getTraceAsString(), |
| 283 | - ) ); |
|
| 283 | + )); |
|
| 284 | 284 | } |
| 285 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 285 | + catch (\Aimeos\MShop\Exception $e) |
|
| 286 | 286 | { |
| 287 | 287 | $status = 404; |
| 288 | - $view->errors = array( array( |
|
| 289 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 288 | + $view->errors = array(array( |
|
| 289 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 290 | 290 | 'detail' => $e->getTraceAsString(), |
| 291 | - ) ); |
|
| 291 | + )); |
|
| 292 | 292 | } |
| 293 | - catch( \Exception $e ) |
|
| 293 | + catch (\Exception $e) |
|
| 294 | 294 | { |
| 295 | 295 | $status = 500; |
| 296 | - $view->errors = array( array( |
|
| 296 | + $view->errors = array(array( |
|
| 297 | 297 | 'title' => $e->getMessage(), |
| 298 | 298 | 'detail' => $e->getTraceAsString(), |
| 299 | - ) ); |
|
| 299 | + )); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** admin/jsonadm/standard/template-post |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $tplconf = 'admin/jsonadm/standard/template-post'; |
| 327 | 327 | $default = 'post-default.php'; |
| 328 | 328 | |
| 329 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 329 | + return $view->render($view->config($tplconf, $default)); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | |
@@ -338,15 +338,15 @@ discard block |
||
| 338 | 338 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 339 | 339 | * @return string Content for response body |
| 340 | 340 | */ |
| 341 | - public function put( $body, array &$header, &$status ) |
|
| 341 | + public function put($body, array &$header, &$status) |
|
| 342 | 342 | { |
| 343 | 343 | $status = 501; |
| 344 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 344 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 345 | 345 | $view = $this->getView(); |
| 346 | 346 | |
| 347 | - $view->errors = array( array( |
|
| 348 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
| 349 | - ) ); |
|
| 347 | + $view->errors = array(array( |
|
| 348 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
| 349 | + )); |
|
| 350 | 350 | |
| 351 | 351 | /** admin/jsonadm/standard/template-put |
| 352 | 352 | * Relative path to the JSON API template for PUT requests |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $tplconf = 'admin/jsonadm/standard/template-put'; |
| 376 | 376 | $default = 'put-default.php'; |
| 377 | 377 | |
| 378 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 378 | + return $view->render($view->config($tplconf, $default)); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 388 | 388 | * @return string Content for response body |
| 389 | 389 | */ |
| 390 | - public function options( $body, array &$header, &$status ) |
|
| 390 | + public function options($body, array &$header, &$status) |
|
| 391 | 391 | { |
| 392 | 392 | $context = $this->getContext(); |
| 393 | 393 | $view = $this->getView(); |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | { |
| 397 | 397 | $resources = $attributes = array(); |
| 398 | 398 | |
| 399 | - foreach( $this->getDomains( $view ) as $domain ) |
|
| 399 | + foreach ($this->getDomains($view) as $domain) |
|
| 400 | 400 | { |
| 401 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 402 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
| 403 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
| 401 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 402 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
| 403 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $view->resources = $resources; |
@@ -412,21 +412,21 @@ discard block |
||
| 412 | 412 | ); |
| 413 | 413 | $status = 200; |
| 414 | 414 | } |
| 415 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 415 | + catch (\Aimeos\MShop\Exception $e) |
|
| 416 | 416 | { |
| 417 | 417 | $status = 404; |
| 418 | - $view->errors = array( array( |
|
| 419 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 418 | + $view->errors = array(array( |
|
| 419 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 420 | 420 | 'detail' => $e->getTraceAsString(), |
| 421 | - ) ); |
|
| 421 | + )); |
|
| 422 | 422 | } |
| 423 | - catch( \Exception $e ) |
|
| 423 | + catch (\Exception $e) |
|
| 424 | 424 | { |
| 425 | 425 | $status = 500; |
| 426 | - $view->errors = array( array( |
|
| 426 | + $view->errors = array(array( |
|
| 427 | 427 | 'title' => $e->getMessage(), |
| 428 | 428 | 'detail' => $e->getTraceAsString(), |
| 429 | - ) ); |
|
| 429 | + )); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** admin/jsonadm/standard/template-options |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $tplconf = 'admin/jsonadm/standard/template-options'; |
| 457 | 457 | $default = 'options-default.php'; |
| 458 | 458 | |
| 459 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 459 | + return $view->render($view->config($tplconf, $default)); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
@@ -468,23 +468,23 @@ discard block |
||
| 468 | 468 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
| 469 | 469 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
| 470 | 470 | */ |
| 471 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
| 471 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
| 472 | 472 | { |
| 473 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 473 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 474 | 474 | |
| 475 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 475 | + if (($id = $view->param('id')) == null) |
|
| 476 | 476 | { |
| 477 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
| 478 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 477 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
| 478 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - $ids = $this->getIds( $request ); |
|
| 482 | - $manager->deleteItems( $ids ); |
|
| 483 | - $view->total = count( $ids ); |
|
| 481 | + $ids = $this->getIds($request); |
|
| 482 | + $manager->deleteItems($ids); |
|
| 483 | + $view->total = count($ids); |
|
| 484 | 484 | } |
| 485 | 485 | else |
| 486 | 486 | { |
| 487 | - $manager->deleteItem( $id ); |
|
| 487 | + $manager->deleteItem($id); |
|
| 488 | 488 | $view->total = 1; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -498,27 +498,27 @@ discard block |
||
| 498 | 498 | * @param \Aimeos\MW\View\Iface $view View instance |
| 499 | 499 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 500 | 500 | */ |
| 501 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
| 501 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
| 502 | 502 | { |
| 503 | 503 | $total = 1; |
| 504 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 505 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 504 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 505 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 506 | 506 | |
| 507 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 507 | + if (($id = $view->param('id')) == null) |
|
| 508 | 508 | { |
| 509 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 510 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 511 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 512 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 509 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 510 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 511 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 512 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 513 | 513 | } |
| 514 | 514 | else |
| 515 | 515 | { |
| 516 | - $view->data = $manager->getItem( $id, array() ); |
|
| 517 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
| 518 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 516 | + $view->data = $manager->getItem($id, array()); |
|
| 517 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
| 518 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 521 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 522 | 522 | $view->total = $total; |
| 523 | 523 | |
| 524 | 524 | return $view; |
@@ -542,11 +542,11 @@ discard block |
||
| 542 | 542 | * @param array $params List of criteria data with condition, sorting and paging |
| 543 | 543 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
| 544 | 544 | */ |
| 545 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 545 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 546 | 546 | { |
| 547 | - $this->initCriteriaConditions( $criteria, $params ); |
|
| 548 | - $this->initCriteriaSortations( $criteria, $params ); |
|
| 549 | - $this->initCriteriaSlice( $criteria, $params ); |
|
| 547 | + $this->initCriteriaConditions($criteria, $params); |
|
| 548 | + $this->initCriteriaSortations($criteria, $params); |
|
| 549 | + $this->initCriteriaSlice($criteria, $params); |
|
| 550 | 550 | |
| 551 | 551 | return $criteria; |
| 552 | 552 | } |
@@ -558,15 +558,15 @@ discard block |
||
| 558 | 558 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 559 | 559 | * @param array $params List of criteria data with condition, sorting and paging |
| 560 | 560 | */ |
| 561 | - private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 561 | + private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 562 | 562 | { |
| 563 | - if( isset( $params['filter'] ) ) |
|
| 563 | + if (isset($params['filter'])) |
|
| 564 | 564 | { |
| 565 | 565 | $existing = $criteria->getConditions(); |
| 566 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
| 566 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
| 567 | 567 | |
| 568 | - $expr = array( $criteria->getConditions(), $existing ); |
|
| 569 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
| 568 | + $expr = array($criteria->getConditions(), $existing); |
|
| 569 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
@@ -577,12 +577,12 @@ discard block |
||
| 577 | 577 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 578 | 578 | * @param array $params List of criteria data with condition, sorting and paging |
| 579 | 579 | */ |
| 580 | - private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 580 | + private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 581 | 581 | { |
| 582 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
| 583 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
| 582 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
| 583 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
| 584 | 584 | |
| 585 | - $criteria->setSlice( $start, $size ); |
|
| 585 | + $criteria->setSlice($start, $size); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
@@ -592,24 +592,24 @@ discard block |
||
| 592 | 592 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 593 | 593 | * @param array $params List of criteria data with condition, sorting and paging |
| 594 | 594 | */ |
| 595 | - private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 595 | + private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 596 | 596 | { |
| 597 | - if( !isset( $params['sort'] ) ) { |
|
| 597 | + if (!isset($params['sort'])) { |
|
| 598 | 598 | return; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | $sortation = array(); |
| 602 | 602 | |
| 603 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
| 603 | + foreach (explode(',', $params['sort']) as $sort) |
|
| 604 | 604 | { |
| 605 | - if( $sort[0] === '-' ) { |
|
| 606 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
| 605 | + if ($sort[0] === '-') { |
|
| 606 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
| 607 | 607 | } else { |
| 608 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
| 608 | + $sortation[] = $criteria->sort('+', $sort); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - $criteria->setSortations( $sortation ); |
|
| 612 | + $criteria->setSortations($sortation); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | |
@@ -619,9 +619,9 @@ discard block |
||
| 619 | 619 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
| 620 | 620 | * @return array List of domain names |
| 621 | 621 | */ |
| 622 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
| 622 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
| 623 | 623 | { |
| 624 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
| 624 | + if (($domains = $view->param('resource')) == '') |
|
| 625 | 625 | { |
| 626 | 626 | /** admin/jsonadm/domains |
| 627 | 627 | * A list of domain names whose clients are available for the JSON API |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
| 644 | 644 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
| 645 | 645 | ); |
| 646 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
| 646 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | return (array) $domains; |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | * @param array $include List of resource types that should be fetched |
| 658 | 658 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 659 | 659 | */ |
| 660 | - protected function getChildItems( array $items, array $include ) |
|
| 660 | + protected function getChildItems(array $items, array $include) |
|
| 661 | 661 | { |
| 662 | 662 | return array(); |
| 663 | 663 | } |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | * @param array $include List of resource types that should be fetched |
| 671 | 671 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 672 | 672 | */ |
| 673 | - protected function getListItems( array $items, array $include ) |
|
| 673 | + protected function getListItems(array $items, array $include) |
|
| 674 | 674 | { |
| 675 | 675 | return array(); |
| 676 | 676 | } |
@@ -682,23 +682,23 @@ discard block |
||
| 682 | 682 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 683 | 683 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 684 | 684 | */ |
| 685 | - protected function getRefItems( array $listItems ) |
|
| 685 | + protected function getRefItems(array $listItems) |
|
| 686 | 686 | { |
| 687 | 687 | $list = $map = array(); |
| 688 | 688 | $context = $this->getContext(); |
| 689 | 689 | |
| 690 | - foreach( $listItems as $listItem ) { |
|
| 690 | + foreach ($listItems as $listItem) { |
|
| 691 | 691 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - foreach( $map as $domain => $ids ) |
|
| 694 | + foreach ($map as $domain => $ids) |
|
| 695 | 695 | { |
| 696 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 696 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 697 | 697 | |
| 698 | 698 | $search = $manager->createSearch(); |
| 699 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
| 699 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
| 700 | 700 | |
| 701 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
| 701 | + $list = array_merge($list, $manager->searchItems($search)); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return $list; |
@@ -711,15 +711,15 @@ discard block |
||
| 711 | 711 | * @param \stdClass $request Decoded request body |
| 712 | 712 | * @return array List of item IDs |
| 713 | 713 | */ |
| 714 | - protected function getIds( $request ) |
|
| 714 | + protected function getIds($request) |
|
| 715 | 715 | { |
| 716 | 716 | $ids = array(); |
| 717 | 717 | |
| 718 | - if( isset( $request->data ) ) |
|
| 718 | + if (isset($request->data)) |
|
| 719 | 719 | { |
| 720 | - foreach( (array) $request->data as $entry ) |
|
| 720 | + foreach ((array) $request->data as $entry) |
|
| 721 | 721 | { |
| 722 | - if( isset( $entry->id ) ) { |
|
| 722 | + if (isset($entry->id)) { |
|
| 723 | 723 | $ids[] = $entry->id; |
| 724 | 724 | } |
| 725 | 725 | } |
@@ -771,33 +771,33 @@ discard block |
||
| 771 | 771 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
| 772 | 772 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 773 | 773 | */ |
| 774 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 774 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 775 | 775 | { |
| 776 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 777 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 776 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 777 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 780 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 781 | 781 | |
| 782 | - if( is_array( $request->data ) ) |
|
| 782 | + if (is_array($request->data)) |
|
| 783 | 783 | { |
| 784 | - $data = $this->saveData( $manager, $request ); |
|
| 784 | + $data = $this->saveData($manager, $request); |
|
| 785 | 785 | |
| 786 | 786 | $view->data = $data; |
| 787 | - $view->total = count( $data ); |
|
| 787 | + $view->total = count($data); |
|
| 788 | 788 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 789 | 789 | } |
| 790 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 790 | + elseif (($id = $view->param('id')) != null) |
|
| 791 | 791 | { |
| 792 | 792 | $request->data->id = $id; |
| 793 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 793 | + $data = $this->saveEntry($manager, $request->data); |
|
| 794 | 794 | |
| 795 | 795 | $view->data = $data; |
| 796 | 796 | $view->total = 1; |
| 797 | 797 | } |
| 798 | 798 | else |
| 799 | 799 | { |
| 800 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
| 800 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | return $view; |
@@ -812,31 +812,31 @@ discard block |
||
| 812 | 812 | * @param array &$header Associative list of HTTP headers as value/result parameter |
| 813 | 813 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 814 | 814 | */ |
| 815 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 815 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 816 | 816 | { |
| 817 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 818 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 817 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 818 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
| 822 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
| 821 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
| 822 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | |
| 826 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 826 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 827 | 827 | |
| 828 | - if( is_array( $request->data ) ) |
|
| 828 | + if (is_array($request->data)) |
|
| 829 | 829 | { |
| 830 | - $data = $this->saveData( $manager, $request ); |
|
| 830 | + $data = $this->saveData($manager, $request); |
|
| 831 | 831 | |
| 832 | 832 | $view->data = $data; |
| 833 | - $view->total = count( $data ); |
|
| 833 | + $view->total = count($data); |
|
| 834 | 834 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 835 | 835 | } |
| 836 | 836 | else |
| 837 | 837 | { |
| 838 | 838 | $request->data->id = null; |
| 839 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 839 | + $data = $this->saveEntry($manager, $request->data); |
|
| 840 | 840 | |
| 841 | 841 | $view->data = $data; |
| 842 | 842 | $view->total = 1; |
@@ -853,14 +853,14 @@ discard block |
||
| 853 | 853 | * @param \stdClass $request Object with request body data |
| 854 | 854 | * @return array List of items |
| 855 | 855 | */ |
| 856 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
| 856 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
| 857 | 857 | { |
| 858 | 858 | $data = array(); |
| 859 | 859 | |
| 860 | - if( isset( $request->data ) ) |
|
| 860 | + if (isset($request->data)) |
|
| 861 | 861 | { |
| 862 | - foreach( (array) $request->data as $entry ) { |
|
| 863 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
| 862 | + foreach ((array) $request->data as $entry) { |
|
| 863 | + $data[] = $this->saveEntry($manager, $entry); |
|
| 864 | 864 | } |
| 865 | 865 | } |
| 866 | 866 | |
@@ -875,22 +875,22 @@ discard block |
||
| 875 | 875 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 876 | 876 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 877 | 877 | */ |
| 878 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 878 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 879 | 879 | { |
| 880 | - if( isset( $entry->id ) ) { |
|
| 881 | - $item = $manager->getItem( $entry->id ); |
|
| 880 | + if (isset($entry->id)) { |
|
| 881 | + $item = $manager->getItem($entry->id); |
|
| 882 | 882 | } else { |
| 883 | 883 | $item = $manager->createItem(); |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 887 | - $manager->saveItem( $item ); |
|
| 886 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 887 | + $manager->saveItem($item); |
|
| 888 | 888 | |
| 889 | - if( isset( $entry->relationships ) ) { |
|
| 890 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 889 | + if (isset($entry->relationships)) { |
|
| 890 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - return $manager->getItem( $item->getId() ); |
|
| 893 | + return $manager->getItem($item->getId()); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -901,28 +901,28 @@ discard block |
||
| 901 | 901 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
| 902 | 902 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
| 903 | 903 | */ |
| 904 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 905 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
| 904 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 905 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
| 906 | 906 | { |
| 907 | 907 | $id = $item->getId(); |
| 908 | - $listManager = $manager->getSubManager( 'lists' ); |
|
| 908 | + $listManager = $manager->getSubManager('lists'); |
|
| 909 | 909 | |
| 910 | - foreach( (array) $relationships as $domain => $list ) |
|
| 910 | + foreach ((array) $relationships as $domain => $list) |
|
| 911 | 911 | { |
| 912 | - if( isset( $list->data ) ) |
|
| 912 | + if (isset($list->data)) |
|
| 913 | 913 | { |
| 914 | - foreach( (array) $list->data as $data ) |
|
| 914 | + foreach ((array) $list->data as $data) |
|
| 915 | 915 | { |
| 916 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
| 916 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
| 917 | 917 | |
| 918 | - if( isset( $data->id ) ) { |
|
| 919 | - $listItem->setRefId( $data->id ); |
|
| 918 | + if (isset($data->id)) { |
|
| 919 | + $listItem->setRefId($data->id); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - $listItem->setParentId( $id ); |
|
| 923 | - $listItem->setDomain( $domain ); |
|
| 922 | + $listItem->setParentId($id); |
|
| 923 | + $listItem->setDomain($domain); |
|
| 924 | 924 | |
| 925 | - $listManager->saveItem( $listItem, false ); |
|
| 925 | + $listManager->saveItem($listItem, false); |
|
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | 928 | } |
@@ -939,20 +939,20 @@ discard block |
||
| 939 | 939 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
| 940 | 940 | */ |
| 941 | 941 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
| 942 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
| 942 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
| 943 | 943 | { |
| 944 | - if( isset( $data->attributes ) ) |
|
| 944 | + if (isset($data->attributes)) |
|
| 945 | 945 | { |
| 946 | 946 | $attr = (array) $data->attributes; |
| 947 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
| 947 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
| 948 | 948 | |
| 949 | - if( isset( $attr[$key.'.type'] ) ) |
|
| 949 | + if (isset($attr[$key . '.type'])) |
|
| 950 | 950 | { |
| 951 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
| 952 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
| 951 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
| 952 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - $item->fromArray( $attr ); |
|
| 955 | + $item->fromArray($attr); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | return $item; |
@@ -59,24 +59,21 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $view = $this->deleteItems( $view, $body ); |
| 61 | 61 | $status = 200; |
| 62 | - } |
|
| 63 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 62 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 64 | 63 | { |
| 65 | 64 | $status = $e->getCode(); |
| 66 | 65 | $view->errors = array( array( |
| 67 | 66 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 68 | 67 | 'detail' => $e->getTraceAsString(), |
| 69 | 68 | ) ); |
| 70 | - } |
|
| 71 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 69 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 72 | 70 | { |
| 73 | 71 | $status = 404; |
| 74 | 72 | $view->errors = array( array( |
| 75 | 73 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 76 | 74 | 'detail' => $e->getTraceAsString(), |
| 77 | 75 | ) ); |
| 78 | - } |
|
| 79 | - catch( \Exception $e ) |
|
| 76 | + } catch( \Exception $e ) |
|
| 80 | 77 | { |
| 81 | 78 | $status = 500; |
| 82 | 79 | $view->errors = array( array( |
@@ -133,16 +130,14 @@ discard block |
||
| 133 | 130 | { |
| 134 | 131 | $view = $this->getItem( $view ); |
| 135 | 132 | $status = 200; |
| 136 | - } |
|
| 137 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 133 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 138 | 134 | { |
| 139 | 135 | $status = 404; |
| 140 | 136 | $view->errors = array( array( |
| 141 | 137 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 142 | 138 | 'detail' => $e->getTraceAsString(), |
| 143 | 139 | ) ); |
| 144 | - } |
|
| 145 | - catch( \Exception $e ) |
|
| 140 | + } catch( \Exception $e ) |
|
| 146 | 141 | { |
| 147 | 142 | $status = 500; |
| 148 | 143 | $view->errors = array( array( |
@@ -199,24 +194,21 @@ discard block |
||
| 199 | 194 | { |
| 200 | 195 | $view = $this->patchItems( $view, $body, $header ); |
| 201 | 196 | $status = 200; |
| 202 | - } |
|
| 203 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 197 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 204 | 198 | { |
| 205 | 199 | $status = $e->getCode(); |
| 206 | 200 | $view->errors = array( array( |
| 207 | 201 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 208 | 202 | 'detail' => $e->getTraceAsString(), |
| 209 | 203 | ) ); |
| 210 | - } |
|
| 211 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 204 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 212 | 205 | { |
| 213 | 206 | $status = 404; |
| 214 | 207 | $view->errors = array( array( |
| 215 | 208 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 216 | 209 | 'detail' => $e->getTraceAsString(), |
| 217 | 210 | ) ); |
| 218 | - } |
|
| 219 | - catch( \Exception $e ) |
|
| 211 | + } catch( \Exception $e ) |
|
| 220 | 212 | { |
| 221 | 213 | $status = 500; |
| 222 | 214 | $view->errors = array( array( |
@@ -273,24 +265,21 @@ discard block |
||
| 273 | 265 | { |
| 274 | 266 | $view = $this->postItems( $view, $body, $header ); |
| 275 | 267 | $status = 201; |
| 276 | - } |
|
| 277 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 268 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 278 | 269 | { |
| 279 | 270 | $status = $e->getCode(); |
| 280 | 271 | $view->errors = array( array( |
| 281 | 272 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 282 | 273 | 'detail' => $e->getTraceAsString(), |
| 283 | 274 | ) ); |
| 284 | - } |
|
| 285 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 275 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 286 | 276 | { |
| 287 | 277 | $status = 404; |
| 288 | 278 | $view->errors = array( array( |
| 289 | 279 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 290 | 280 | 'detail' => $e->getTraceAsString(), |
| 291 | 281 | ) ); |
| 292 | - } |
|
| 293 | - catch( \Exception $e ) |
|
| 282 | + } catch( \Exception $e ) |
|
| 294 | 283 | { |
| 295 | 284 | $status = 500; |
| 296 | 285 | $view->errors = array( array( |
@@ -411,16 +400,14 @@ discard block |
||
| 411 | 400 | 'Allow' => 'DELETE,GET,POST,OPTIONS' |
| 412 | 401 | ); |
| 413 | 402 | $status = 200; |
| 414 | - } |
|
| 415 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 403 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 416 | 404 | { |
| 417 | 405 | $status = 404; |
| 418 | 406 | $view->errors = array( array( |
| 419 | 407 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 420 | 408 | 'detail' => $e->getTraceAsString(), |
| 421 | 409 | ) ); |
| 422 | - } |
|
| 423 | - catch( \Exception $e ) |
|
| 410 | + } catch( \Exception $e ) |
|
| 424 | 411 | { |
| 425 | 412 | $status = 500; |
| 426 | 413 | $view->errors = array( array( |
@@ -481,8 +468,7 @@ discard block |
||
| 481 | 468 | $ids = $this->getIds( $request ); |
| 482 | 469 | $manager->deleteItems( $ids ); |
| 483 | 470 | $view->total = count( $ids ); |
| 484 | - } |
|
| 485 | - else |
|
| 471 | + } else |
|
| 486 | 472 | { |
| 487 | 473 | $manager->deleteItem( $id ); |
| 488 | 474 | $view->total = 1; |
@@ -510,8 +496,7 @@ discard block |
||
| 510 | 496 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 511 | 497 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 512 | 498 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 513 | - } |
|
| 514 | - else |
|
| 499 | + } else |
|
| 515 | 500 | { |
| 516 | 501 | $view->data = $manager->getItem( $id, array() ); |
| 517 | 502 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -786,16 +771,14 @@ discard block |
||
| 786 | 771 | $view->data = $data; |
| 787 | 772 | $view->total = count( $data ); |
| 788 | 773 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 789 | - } |
|
| 790 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 774 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 791 | 775 | { |
| 792 | 776 | $request->data->id = $id; |
| 793 | 777 | $data = $this->saveEntry( $manager, $request->data ); |
| 794 | 778 | |
| 795 | 779 | $view->data = $data; |
| 796 | 780 | $view->total = 1; |
| 797 | - } |
|
| 798 | - else |
|
| 781 | + } else |
|
| 799 | 782 | { |
| 800 | 783 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
| 801 | 784 | } |
@@ -832,8 +815,7 @@ discard block |
||
| 832 | 815 | $view->data = $data; |
| 833 | 816 | $view->total = count( $data ); |
| 834 | 817 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 835 | - } |
|
| 836 | - else |
|
| 818 | + } else |
|
| 837 | 819 | { |
| 838 | 820 | $request->data->id = null; |
| 839 | 821 | $data = $this->saveEntry( $manager, $request->data ); |