@@ -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 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
92 | 92 | $default = 'delete-default.php'; |
93 | 93 | |
94 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
94 | + return $view->render($view->config($tplconf, $default)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -103,31 +103,31 @@ discard block |
||
103 | 103 | * @param integer &$status Variable which contains the HTTP status afterwards |
104 | 104 | * @return string Content for response body |
105 | 105 | */ |
106 | - public function get( $body, array &$header, &$status ) |
|
106 | + public function get($body, array &$header, &$status) |
|
107 | 107 | { |
108 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
108 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
109 | 109 | $view = $this->getView(); |
110 | 110 | |
111 | 111 | try |
112 | 112 | { |
113 | - $view = $this->getItem( $view ); |
|
113 | + $view = $this->getItem($view); |
|
114 | 114 | $status = 200; |
115 | 115 | } |
116 | - catch( \Aimeos\MShop\Exception $e ) |
|
116 | + catch (\Aimeos\MShop\Exception $e) |
|
117 | 117 | { |
118 | 118 | $status = 404; |
119 | - $view->errors = array( array( |
|
120 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
119 | + $view->errors = array(array( |
|
120 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
121 | 121 | 'detail' => $e->getTraceAsString(), |
122 | - ) ); |
|
122 | + )); |
|
123 | 123 | } |
124 | - catch( \Exception $e ) |
|
124 | + catch (\Exception $e) |
|
125 | 125 | { |
126 | 126 | $status = 500; |
127 | - $view->errors = array( array( |
|
127 | + $view->errors = array(array( |
|
128 | 128 | 'title' => $e->getMessage(), |
129 | 129 | 'detail' => $e->getTraceAsString(), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** admin/jsonadm/standard/template-get |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $tplconf = 'admin/jsonadm/standard/template-get'; |
158 | 158 | $default = 'get-default.php'; |
159 | 159 | |
160 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
160 | + return $view->render($view->config($tplconf, $default)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -169,39 +169,39 @@ discard block |
||
169 | 169 | * @param integer &$status Variable which contains the HTTP status afterwards |
170 | 170 | * @return string Content for response body |
171 | 171 | */ |
172 | - public function patch( $body, array &$header, &$status ) |
|
172 | + public function patch($body, array &$header, &$status) |
|
173 | 173 | { |
174 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
174 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
175 | 175 | $view = $this->getView(); |
176 | 176 | |
177 | 177 | try |
178 | 178 | { |
179 | - $view = $this->patchItems( $view, $body, $header ); |
|
179 | + $view = $this->patchItems($view, $body, $header); |
|
180 | 180 | $status = 200; |
181 | 181 | } |
182 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
182 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
183 | 183 | { |
184 | 184 | $status = $e->getCode(); |
185 | - $view->errors = array( array( |
|
186 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
185 | + $view->errors = array(array( |
|
186 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
187 | 187 | 'detail' => $e->getTraceAsString(), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | } |
190 | - catch( \Aimeos\MShop\Exception $e ) |
|
190 | + catch (\Aimeos\MShop\Exception $e) |
|
191 | 191 | { |
192 | 192 | $status = 404; |
193 | - $view->errors = array( array( |
|
194 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
193 | + $view->errors = array(array( |
|
194 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
195 | 195 | 'detail' => $e->getTraceAsString(), |
196 | - ) ); |
|
196 | + )); |
|
197 | 197 | } |
198 | - catch( \Exception $e ) |
|
198 | + catch (\Exception $e) |
|
199 | 199 | { |
200 | 200 | $status = 500; |
201 | - $view->errors = array( array( |
|
201 | + $view->errors = array(array( |
|
202 | 202 | 'title' => $e->getMessage(), |
203 | 203 | 'detail' => $e->getTraceAsString(), |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** admin/jsonadm/standard/template-patch |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
232 | 232 | $default = 'patch-default.php'; |
233 | 233 | |
234 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
234 | + return $view->render($view->config($tplconf, $default)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,39 +243,39 @@ discard block |
||
243 | 243 | * @param integer &$status Variable which contains the HTTP status afterwards |
244 | 244 | * @return string Content for response body |
245 | 245 | */ |
246 | - public function post( $body, array &$header, &$status ) |
|
246 | + public function post($body, array &$header, &$status) |
|
247 | 247 | { |
248 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
248 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
249 | 249 | $view = $this->getView(); |
250 | 250 | |
251 | 251 | try |
252 | 252 | { |
253 | - $view = $this->postItems( $view, $body, $header ); |
|
253 | + $view = $this->postItems($view, $body, $header); |
|
254 | 254 | $status = 201; |
255 | 255 | } |
256 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
256 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
257 | 257 | { |
258 | 258 | $status = $e->getCode(); |
259 | - $view->errors = array( array( |
|
260 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
259 | + $view->errors = array(array( |
|
260 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
261 | 261 | 'detail' => $e->getTraceAsString(), |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | } |
264 | - catch( \Aimeos\MShop\Exception $e ) |
|
264 | + catch (\Aimeos\MShop\Exception $e) |
|
265 | 265 | { |
266 | 266 | $status = 404; |
267 | - $view->errors = array( array( |
|
268 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
267 | + $view->errors = array(array( |
|
268 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
269 | 269 | 'detail' => $e->getTraceAsString(), |
270 | - ) ); |
|
270 | + )); |
|
271 | 271 | } |
272 | - catch( \Exception $e ) |
|
272 | + catch (\Exception $e) |
|
273 | 273 | { |
274 | 274 | $status = 500; |
275 | - $view->errors = array( array( |
|
275 | + $view->errors = array(array( |
|
276 | 276 | 'title' => $e->getMessage(), |
277 | 277 | 'detail' => $e->getTraceAsString(), |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** admin/jsonadm/standard/template-post |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $tplconf = 'admin/jsonadm/standard/template-post'; |
306 | 306 | $default = 'post-default.php'; |
307 | 307 | |
308 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
308 | + return $view->render($view->config($tplconf, $default)); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | * @param integer &$status Variable which contains the HTTP status afterwards |
318 | 318 | * @return string Content for response body |
319 | 319 | */ |
320 | - public function put( $body, array &$header, &$status ) |
|
320 | + public function put($body, array &$header, &$status) |
|
321 | 321 | { |
322 | 322 | $status = 501; |
323 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
323 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
324 | 324 | $view = $this->getView(); |
325 | 325 | |
326 | - $view->errors = array( array( |
|
327 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
328 | - ) ); |
|
326 | + $view->errors = array(array( |
|
327 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
328 | + )); |
|
329 | 329 | |
330 | 330 | /** admin/jsonadm/standard/template-put |
331 | 331 | * Relative path to the JSON API template for PUT requests |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $tplconf = 'admin/jsonadm/standard/template-put'; |
355 | 355 | $default = 'put-default.php'; |
356 | 356 | |
357 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
357 | + return $view->render($view->config($tplconf, $default)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param integer &$status Variable which contains the HTTP status afterwards |
367 | 367 | * @return string Content for response body |
368 | 368 | */ |
369 | - public function options( $body, array &$header, &$status ) |
|
369 | + public function options($body, array &$header, &$status) |
|
370 | 370 | { |
371 | 371 | $context = $this->getContext(); |
372 | 372 | $view = $this->getView(); |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | { |
376 | 376 | $resources = $attributes = array(); |
377 | 377 | |
378 | - foreach( $this->getDomains( $view ) as $domain ) |
|
378 | + foreach ($this->getDomains($view) as $domain) |
|
379 | 379 | { |
380 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
381 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
382 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
380 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
381 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
382 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $view->resources = $resources; |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | ); |
392 | 392 | $status = 200; |
393 | 393 | } |
394 | - catch( \Aimeos\MShop\Exception $e ) |
|
394 | + catch (\Aimeos\MShop\Exception $e) |
|
395 | 395 | { |
396 | 396 | $status = 404; |
397 | - $view->errors = array( array( |
|
398 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
397 | + $view->errors = array(array( |
|
398 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
399 | 399 | 'detail' => $e->getTraceAsString(), |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | } |
402 | - catch( \Exception $e ) |
|
402 | + catch (\Exception $e) |
|
403 | 403 | { |
404 | 404 | $status = 500; |
405 | - $view->errors = array( array( |
|
405 | + $view->errors = array(array( |
|
406 | 406 | 'title' => $e->getMessage(), |
407 | 407 | 'detail' => $e->getTraceAsString(), |
408 | - ) ); |
|
408 | + )); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** admin/jsonadm/standard/template-options |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $tplconf = 'admin/jsonadm/standard/template-options'; |
436 | 436 | $default = 'options-default.php'; |
437 | 437 | |
438 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
438 | + return $view->render($view->config($tplconf, $default)); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,23 +447,23 @@ discard block |
||
447 | 447 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
448 | 448 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
449 | 449 | */ |
450 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
450 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
451 | 451 | { |
452 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
452 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
453 | 453 | |
454 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
454 | + if (($id = $view->param('id')) == null) |
|
455 | 455 | { |
456 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
457 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
456 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
457 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
458 | 458 | } |
459 | 459 | |
460 | - $ids = $this->getIds( $request ); |
|
461 | - $manager->deleteItems( $ids ); |
|
462 | - $view->total = count( $ids ); |
|
460 | + $ids = $this->getIds($request); |
|
461 | + $manager->deleteItems($ids); |
|
462 | + $view->total = count($ids); |
|
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - $manager->deleteItem( $id ); |
|
466 | + $manager->deleteItem($id); |
|
467 | 467 | $view->total = 1; |
468 | 468 | } |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * @param \Aimeos\MW\View\Iface $view View instance |
478 | 478 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
479 | 479 | */ |
480 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
480 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
481 | 481 | { |
482 | 482 | $total = 1; |
483 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
484 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
483 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
484 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
485 | 485 | |
486 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
486 | + if (($id = $view->param('id')) == null) |
|
487 | 487 | { |
488 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
489 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
490 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
491 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
488 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
489 | + $view->data = $manager->searchItems($search, array(), $total); |
|
490 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
491 | + $view->listItems = $this->getListItems($view->data, $include); |
|
492 | 492 | } |
493 | 493 | else |
494 | 494 | { |
495 | - $view->data = $manager->getItem( $id, array() ); |
|
496 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
497 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
495 | + $view->data = $manager->getItem($id, array()); |
|
496 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
497 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
498 | 498 | } |
499 | 499 | |
500 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
500 | + $view->refItems = $this->getRefItems($view->listItems); |
|
501 | 501 | $view->total = $total; |
502 | 502 | |
503 | 503 | return $view; |
@@ -513,33 +513,33 @@ discard block |
||
513 | 513 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
514 | 514 | * @return \Aimeos\MW\View\Iface Updated view instance |
515 | 515 | */ |
516 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
516 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
517 | 517 | { |
518 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
519 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
518 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
519 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
520 | 520 | } |
521 | 521 | |
522 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
522 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
523 | 523 | |
524 | - if( is_array( $request->data ) ) |
|
524 | + if (is_array($request->data)) |
|
525 | 525 | { |
526 | - $data = $this->saveData( $manager, $request ); |
|
526 | + $data = $this->saveData($manager, $request); |
|
527 | 527 | |
528 | 528 | $view->data = $data; |
529 | - $view->total = count( $data ); |
|
529 | + $view->total = count($data); |
|
530 | 530 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
531 | 531 | } |
532 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
532 | + elseif (($id = $view->param('id')) != null) |
|
533 | 533 | { |
534 | 534 | $request->data->id = $id; |
535 | - $data = $this->saveEntry( $manager, $request->data ); |
|
535 | + $data = $this->saveEntry($manager, $request->data); |
|
536 | 536 | |
537 | 537 | $view->data = $data; |
538 | 538 | $view->total = 1; |
539 | 539 | } |
540 | 540 | else |
541 | 541 | { |
542 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
542 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | return $view; |
@@ -554,31 +554,31 @@ discard block |
||
554 | 554 | * @param array &$header Associative list of HTTP headers as value/result parameter |
555 | 555 | * @return \Aimeos\MW\View\Iface Updated view instance |
556 | 556 | */ |
557 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
557 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
558 | 558 | { |
559 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
560 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
559 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
560 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
561 | 561 | } |
562 | 562 | |
563 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
564 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
563 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
564 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | |
568 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
568 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
569 | 569 | |
570 | - if( is_array( $request->data ) ) |
|
570 | + if (is_array($request->data)) |
|
571 | 571 | { |
572 | - $data = $this->saveData( $manager, $request ); |
|
572 | + $data = $this->saveData($manager, $request); |
|
573 | 573 | |
574 | 574 | $view->data = $data; |
575 | - $view->total = count( $data ); |
|
575 | + $view->total = count($data); |
|
576 | 576 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
577 | 577 | } |
578 | 578 | else |
579 | 579 | { |
580 | 580 | $request->data->id = null; |
581 | - $data = $this->saveEntry( $manager, $request->data ); |
|
581 | + $data = $this->saveEntry($manager, $request->data); |
|
582 | 582 | |
583 | 583 | $view->data = $data; |
584 | 584 | $view->total = 1; |
@@ -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; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $include List of resource types that should be fetched |
50 | 50 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
51 | 51 | */ |
52 | - protected function getChildItems( array $items, array $include ) |
|
52 | + protected function getChildItems(array $items, array $include) |
|
53 | 53 | { |
54 | 54 | return array(); |
55 | 55 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
73 | 73 | * @return array List of domain names |
74 | 74 | */ |
75 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
75 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
76 | 76 | { |
77 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
77 | + if (($domains = $view->param('resource')) == '') |
|
78 | 78 | { |
79 | 79 | /** admin/jsonadm/domains |
80 | 80 | * A list of domain names whose clients are available for the JSON API |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
97 | 97 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
98 | 98 | ); |
99 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
99 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return (array) $domains; |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | * @param \stdClass $request Decoded request body |
110 | 110 | * @return array List of item IDs |
111 | 111 | */ |
112 | - protected function getIds( $request ) |
|
112 | + protected function getIds($request) |
|
113 | 113 | { |
114 | 114 | $ids = array(); |
115 | 115 | |
116 | - if( isset( $request->data ) ) |
|
116 | + if (isset($request->data)) |
|
117 | 117 | { |
118 | - foreach( (array) $request->data as $entry ) |
|
118 | + foreach ((array) $request->data as $entry) |
|
119 | 119 | { |
120 | - if( isset( $entry->id ) ) { |
|
120 | + if (isset($entry->id)) { |
|
121 | 121 | $ids[] = $entry->id; |
122 | 122 | } |
123 | 123 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param array $include List of resource types that should be fetched |
135 | 135 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
136 | 136 | */ |
137 | - protected function getListItems( array $items, array $include ) |
|
137 | + protected function getListItems(array $items, array $include) |
|
138 | 138 | { |
139 | 139 | return array(); |
140 | 140 | } |
@@ -157,23 +157,23 @@ discard block |
||
157 | 157 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
158 | 158 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
159 | 159 | */ |
160 | - protected function getRefItems( array $listItems ) |
|
160 | + protected function getRefItems(array $listItems) |
|
161 | 161 | { |
162 | 162 | $list = $map = array(); |
163 | 163 | $context = $this->getContext(); |
164 | 164 | |
165 | - foreach( $listItems as $listItem ) { |
|
165 | + foreach ($listItems as $listItem) { |
|
166 | 166 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
167 | 167 | } |
168 | 168 | |
169 | - foreach( $map as $domain => $ids ) |
|
169 | + foreach ($map as $domain => $ids) |
|
170 | 170 | { |
171 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
171 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
172 | 172 | |
173 | 173 | $search = $manager->createSearch(); |
174 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
174 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
175 | 175 | |
176 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
176 | + $list = array_merge($list, $manager->searchItems($search)); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $list; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param array $params List of criteria data with condition, sorting and paging |
210 | 210 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
211 | 211 | */ |
212 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
212 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
213 | 213 | { |
214 | - $this->initCriteriaConditions( $criteria, $params ); |
|
215 | - $this->initCriteriaSortations( $criteria, $params ); |
|
216 | - $this->initCriteriaSlice( $criteria, $params ); |
|
214 | + $this->initCriteriaConditions($criteria, $params); |
|
215 | + $this->initCriteriaSortations($criteria, $params); |
|
216 | + $this->initCriteriaSlice($criteria, $params); |
|
217 | 217 | |
218 | 218 | return $criteria; |
219 | 219 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
226 | 226 | * @param array $params List of criteria data with condition, sorting and paging |
227 | 227 | */ |
228 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
228 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
229 | 229 | { |
230 | - if( !isset( $params['filter'] ) ) { |
|
230 | + if (!isset($params['filter'])) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $existing = $criteria->getConditions(); |
235 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
235 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
236 | 236 | |
237 | - $expr = array( $criteria->getConditions(), $existing ); |
|
238 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
237 | + $expr = array($criteria->getConditions(), $existing); |
|
238 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
246 | 246 | * @param array $params List of criteria data with condition, sorting and paging |
247 | 247 | */ |
248 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
248 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
249 | 249 | { |
250 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
251 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
250 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
251 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
252 | 252 | |
253 | - $criteria->setSlice( $start, $size ); |
|
253 | + $criteria->setSlice($start, $size); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
261 | 261 | * @param array $params List of criteria data with condition, sorting and paging |
262 | 262 | */ |
263 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
263 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
264 | 264 | { |
265 | - if( !isset( $params['sort'] ) ) { |
|
265 | + if (!isset($params['sort'])) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | |
269 | 269 | $sortation = array(); |
270 | 270 | |
271 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
271 | + foreach (explode(',', $params['sort']) as $sort) |
|
272 | 272 | { |
273 | - if( $sort[0] === '-' ) { |
|
274 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
273 | + if ($sort[0] === '-') { |
|
274 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
275 | 275 | } else { |
276 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
276 | + $sortation[] = $criteria->sort('+', $sort); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - $criteria->setSortations( $sortation ); |
|
280 | + $criteria->setSortations($sortation); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | * @param \stdClass $request Object with request body data |
289 | 289 | * @return array List of items |
290 | 290 | */ |
291 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
291 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
292 | 292 | { |
293 | 293 | $data = array(); |
294 | 294 | |
295 | - if( isset( $request->data ) ) |
|
295 | + if (isset($request->data)) |
|
296 | 296 | { |
297 | - foreach( (array) $request->data as $entry ) { |
|
298 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
297 | + foreach ((array) $request->data as $entry) { |
|
298 | + $data[] = $this->saveEntry($manager, $entry); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | * @param \stdClass $entry Object including "id" and "attributes" elements |
311 | 311 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
312 | 312 | */ |
313 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
313 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
314 | 314 | { |
315 | - if( isset( $entry->id ) ) { |
|
316 | - $item = $manager->getItem( $entry->id ); |
|
315 | + if (isset($entry->id)) { |
|
316 | + $item = $manager->getItem($entry->id); |
|
317 | 317 | } else { |
318 | 318 | $item = $manager->createItem(); |
319 | 319 | } |
320 | 320 | |
321 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
322 | - $manager->saveItem( $item ); |
|
321 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
322 | + $manager->saveItem($item); |
|
323 | 323 | |
324 | - if( isset( $entry->relationships ) ) { |
|
325 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
324 | + if (isset($entry->relationships)) { |
|
325 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
326 | 326 | } |
327 | 327 | |
328 | - return $manager->getItem( $item->getId() ); |
|
328 | + return $manager->getItem($item->getId()); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
337 | 337 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
338 | 338 | */ |
339 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
339 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
341 | 341 | { |
342 | 342 | $id = $item->getId(); |
343 | - $listManager = $manager->getSubManager( 'lists' ); |
|
343 | + $listManager = $manager->getSubManager('lists'); |
|
344 | 344 | |
345 | - foreach( (array) $relationships as $domain => $list ) |
|
345 | + foreach ((array) $relationships as $domain => $list) |
|
346 | 346 | { |
347 | - if( isset( $list->data ) ) |
|
347 | + if (isset($list->data)) |
|
348 | 348 | { |
349 | - foreach( (array) $list->data as $data ) |
|
349 | + foreach ((array) $list->data as $data) |
|
350 | 350 | { |
351 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
351 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
352 | 352 | |
353 | - if( isset( $data->id ) ) { |
|
354 | - $listItem->setRefId( $data->id ); |
|
353 | + if (isset($data->id)) { |
|
354 | + $listItem->setRefId($data->id); |
|
355 | 355 | } |
356 | 356 | |
357 | - $listItem->setParentId( $id ); |
|
358 | - $listItem->setDomain( $domain ); |
|
357 | + $listItem->setParentId($id); |
|
358 | + $listItem->setDomain($domain); |
|
359 | 359 | |
360 | - $listManager->saveItem( $listItem, false ); |
|
360 | + $listManager->saveItem($listItem, false); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
@@ -374,20 +374,20 @@ discard block |
||
374 | 374 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
375 | 375 | */ |
376 | 376 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
377 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
377 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
378 | 378 | { |
379 | - if( isset( $data->attributes ) ) |
|
379 | + if (isset($data->attributes)) |
|
380 | 380 | { |
381 | 381 | $attr = (array) $data->attributes; |
382 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
382 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
383 | 383 | |
384 | - if( isset( $attr[$key.'.type'] ) ) |
|
384 | + if (isset($attr[$key . '.type'])) |
|
385 | 385 | { |
386 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
387 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
386 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
387 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
388 | 388 | } |
389 | 389 | |
390 | - $item->fromArray( $attr ); |
|
390 | + $item->fromArray($attr); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return $item; |