@@ -1,10 +1,10 @@ |
||
1 | 1 | { |
2 | 2 | "meta": { |
3 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
3 | + "total": <?php echo $this->get('total', 0); ?> |
|
4 | 4 | |
5 | 5 | } |
6 | -<?php if( isset( $this->errors ) ) : ?> |
|
7 | - ,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
6 | +<?php if (isset($this->errors)) : ?> |
|
7 | + ,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
8 | 8 | <?php endif; ?> |
9 | 9 | |
10 | 10 | } |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * @param string $body Request body |
50 | 50 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
51 | 51 | * @param integer &$status Variable which contains the HTTP status afterwards |
52 | + * @param integer $status |
|
52 | 53 | * @return string Content for response body |
53 | 54 | */ |
54 | 55 | public function delete( $body, array &$header, &$status ) |
@@ -252,6 +253,7 @@ discard block |
||
252 | 253 | * @param string $body Request body |
253 | 254 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
254 | 255 | * @param integer &$status Variable which contains the HTTP status afterwards |
256 | + * @param integer $status |
|
255 | 257 | * @return string Content for response body |
256 | 258 | */ |
257 | 259 | public function patch( $body, array &$header, &$status ) |
@@ -380,6 +382,7 @@ discard block |
||
380 | 382 | * @param string $body Request body |
381 | 383 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
382 | 384 | * @param integer &$status Variable which contains the HTTP status afterwards |
385 | + * @param integer $status |
|
383 | 386 | * @return string Content for response body |
384 | 387 | */ |
385 | 388 | public function post( $body, array &$header, &$status ) |
@@ -508,6 +511,7 @@ discard block |
||
508 | 511 | * @param string $body Request body |
509 | 512 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
510 | 513 | * @param integer &$status Variable which contains the HTTP status afterwards |
514 | + * @param integer $status |
|
511 | 515 | * @return string Content for response body |
512 | 516 | */ |
513 | 517 | public function put( $body, array &$header, &$status ) |
@@ -559,6 +563,7 @@ discard block |
||
559 | 563 | * @param string $body Request body |
560 | 564 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
561 | 565 | * @param integer &$status Variable which contains the HTTP status afterwards |
566 | + * @param integer $status |
|
562 | 567 | * @return string Content for response body |
563 | 568 | */ |
564 | 569 | public function options( $body, array &$header, &$status ) |
@@ -61,32 +61,28 @@ discard block |
||
61 | 61 | { |
62 | 62 | $view = $this->deleteItems( $view, $body ); |
63 | 63 | $status = 200; |
64 | - } |
|
65 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
64 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
66 | 65 | { |
67 | 66 | $status = $e->getCode(); |
68 | 67 | $view->errors = array( array( |
69 | 68 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
70 | 69 | 'detail' => $e->getTraceAsString(), |
71 | 70 | ) ); |
72 | - } |
|
73 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
71 | + } catch( \Aimeos\MAdmin\Exception $e ) |
|
74 | 72 | { |
75 | 73 | $status = 404; |
76 | 74 | $view->errors = array( array( |
77 | 75 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
78 | 76 | 'detail' => $e->getTraceAsString(), |
79 | 77 | ) ); |
80 | - } |
|
81 | - catch( \Aimeos\MShop\Exception $e ) |
|
78 | + } catch( \Aimeos\MShop\Exception $e ) |
|
82 | 79 | { |
83 | 80 | $status = 404; |
84 | 81 | $view->errors = array( array( |
85 | 82 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
86 | 83 | 'detail' => $e->getTraceAsString(), |
87 | 84 | ) ); |
88 | - } |
|
89 | - catch( \Exception $e ) |
|
85 | + } catch( \Exception $e ) |
|
90 | 86 | { |
91 | 87 | $status = 500; |
92 | 88 | $view->errors = array( array( |
@@ -143,24 +139,21 @@ discard block |
||
143 | 139 | { |
144 | 140 | $view = $this->getItem( $view ); |
145 | 141 | $status = 200; |
146 | - } |
|
147 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
142 | + } catch( \Aimeos\MAdmin\Exception $e ) |
|
148 | 143 | { |
149 | 144 | $status = 404; |
150 | 145 | $view->errors = array( array( |
151 | 146 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
152 | 147 | 'detail' => $e->getTraceAsString(), |
153 | 148 | ) ); |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
149 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 150 | { |
157 | 151 | $status = 404; |
158 | 152 | $view->errors = array( array( |
159 | 153 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
160 | 154 | 'detail' => $e->getTraceAsString(), |
161 | 155 | ) ); |
162 | - } |
|
163 | - catch( \Exception $e ) |
|
156 | + } catch( \Exception $e ) |
|
164 | 157 | { |
165 | 158 | $status = 500; |
166 | 159 | $view->errors = array( array( |
@@ -218,32 +211,28 @@ discard block |
||
218 | 211 | { |
219 | 212 | $view = $this->patchItems( $view, $body, $header ); |
220 | 213 | $status = 200; |
221 | - } |
|
222 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
214 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
223 | 215 | { |
224 | 216 | $status = $e->getCode(); |
225 | 217 | $view->errors = array( array( |
226 | 218 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
227 | 219 | 'detail' => $e->getTraceAsString(), |
228 | 220 | ) ); |
229 | - } |
|
230 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
221 | + } catch( \Aimeos\MAdmin\Exception $e ) |
|
231 | 222 | { |
232 | 223 | $status = 404; |
233 | 224 | $view->errors = array( array( |
234 | 225 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
235 | 226 | 'detail' => $e->getTraceAsString(), |
236 | 227 | ) ); |
237 | - } |
|
238 | - catch( \Aimeos\MShop\Exception $e ) |
|
228 | + } catch( \Aimeos\MShop\Exception $e ) |
|
239 | 229 | { |
240 | 230 | $status = 404; |
241 | 231 | $view->errors = array( array( |
242 | 232 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
243 | 233 | 'detail' => $e->getTraceAsString(), |
244 | 234 | ) ); |
245 | - } |
|
246 | - catch( \Exception $e ) |
|
235 | + } catch( \Exception $e ) |
|
247 | 236 | { |
248 | 237 | $status = 500; |
249 | 238 | $view->errors = array( array( |
@@ -301,32 +290,28 @@ discard block |
||
301 | 290 | { |
302 | 291 | $view = $this->postItems( $view, $body, $header ); |
303 | 292 | $status = 201; |
304 | - } |
|
305 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
293 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
306 | 294 | { |
307 | 295 | $status = $e->getCode(); |
308 | 296 | $view->errors = array( array( |
309 | 297 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
310 | 298 | 'detail' => $e->getTraceAsString(), |
311 | 299 | ) ); |
312 | - } |
|
313 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
300 | + } catch( \Aimeos\MAdmin\Exception $e ) |
|
314 | 301 | { |
315 | 302 | $status = 404; |
316 | 303 | $view->errors = array( array( |
317 | 304 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
318 | 305 | 'detail' => $e->getTraceAsString(), |
319 | 306 | ) ); |
320 | - } |
|
321 | - catch( \Aimeos\MShop\Exception $e ) |
|
307 | + } catch( \Aimeos\MShop\Exception $e ) |
|
322 | 308 | { |
323 | 309 | $status = 404; |
324 | 310 | $view->errors = array( array( |
325 | 311 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
326 | 312 | 'detail' => $e->getTraceAsString(), |
327 | 313 | ) ); |
328 | - } |
|
329 | - catch( \Exception $e ) |
|
314 | + } catch( \Exception $e ) |
|
330 | 315 | { |
331 | 316 | $status = 500; |
332 | 317 | $view->errors = array( array( |
@@ -449,24 +434,21 @@ discard block |
||
449 | 434 | 'Allow' => 'DELETE,GET,POST,OPTIONS' |
450 | 435 | ); |
451 | 436 | $status = 200; |
452 | - } |
|
453 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
437 | + } catch( \Aimeos\MAdmin\Exception $e ) |
|
454 | 438 | { |
455 | 439 | $status = 404; |
456 | 440 | $view->errors = array( array( |
457 | 441 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
458 | 442 | 'detail' => $e->getTraceAsString(), |
459 | 443 | ) ); |
460 | - } |
|
461 | - catch( \Aimeos\MShop\Exception $e ) |
|
444 | + } catch( \Aimeos\MShop\Exception $e ) |
|
462 | 445 | { |
463 | 446 | $status = 404; |
464 | 447 | $view->errors = array( array( |
465 | 448 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
466 | 449 | 'detail' => $e->getTraceAsString(), |
467 | 450 | ) ); |
468 | - } |
|
469 | - catch( \Exception $e ) |
|
451 | + } catch( \Exception $e ) |
|
470 | 452 | { |
471 | 453 | $status = 500; |
472 | 454 | $view->errors = array( array( |
@@ -535,8 +517,7 @@ discard block |
||
535 | 517 | |
536 | 518 | $manager->deleteItems( $ids ); |
537 | 519 | $view->total = count( $ids ); |
538 | - } |
|
539 | - else |
|
520 | + } else |
|
540 | 521 | { |
541 | 522 | $manager->deleteItem( $id ); |
542 | 523 | $view->total = 1; |
@@ -564,8 +545,7 @@ discard block |
||
564 | 545 | $view->data = $manager->searchItems( $search, array(), $total ); |
565 | 546 | $view->childItems = $this->getChildItems( $view->data, $include ); |
566 | 547 | $view->listItems = $this->getListItems( $view->data, $include ); |
567 | - } |
|
568 | - else |
|
548 | + } else |
|
569 | 549 | { |
570 | 550 | $view->data = $manager->getItem( $id, array() ); |
571 | 551 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -816,8 +796,7 @@ discard block |
||
816 | 796 | $view->data = $data; |
817 | 797 | $view->total = count( $data ); |
818 | 798 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
819 | - } |
|
820 | - else |
|
799 | + } else |
|
821 | 800 | { |
822 | 801 | if( ( $id = $view->param( 'id' ) ) == null ) { |
823 | 802 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
@@ -862,8 +841,7 @@ discard block |
||
862 | 841 | $view->data = $data; |
863 | 842 | $view->total = count( $data ); |
864 | 843 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
865 | - } |
|
866 | - else |
|
844 | + } else |
|
867 | 845 | { |
868 | 846 | $request->data->id = null; |
869 | 847 | $data = $this->saveEntry( $manager, $request->data ); |
@@ -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,48 +50,48 @@ 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 | $context = $this->getContext(); |
57 | 57 | $view = $this->getView(); |
58 | 58 | |
59 | 59 | try |
60 | 60 | { |
61 | - $view = $this->deleteItems( $view, $body ); |
|
61 | + $view = $this->deleteItems($view, $body); |
|
62 | 62 | $status = 200; |
63 | 63 | } |
64 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
64 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
65 | 65 | { |
66 | 66 | $status = $e->getCode(); |
67 | - $view->errors = array( array( |
|
68 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
67 | + $view->errors = array(array( |
|
68 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
69 | 69 | 'detail' => $e->getTraceAsString(), |
70 | - ) ); |
|
70 | + )); |
|
71 | 71 | } |
72 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
72 | + catch (\Aimeos\MAdmin\Exception $e) |
|
73 | 73 | { |
74 | 74 | $status = 404; |
75 | - $view->errors = array( array( |
|
76 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
75 | + $view->errors = array(array( |
|
76 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
77 | 77 | 'detail' => $e->getTraceAsString(), |
78 | - ) ); |
|
78 | + )); |
|
79 | 79 | } |
80 | - catch( \Aimeos\MShop\Exception $e ) |
|
80 | + catch (\Aimeos\MShop\Exception $e) |
|
81 | 81 | { |
82 | 82 | $status = 404; |
83 | - $view->errors = array( array( |
|
84 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
83 | + $view->errors = array(array( |
|
84 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
85 | 85 | 'detail' => $e->getTraceAsString(), |
86 | - ) ); |
|
86 | + )); |
|
87 | 87 | } |
88 | - catch( \Exception $e ) |
|
88 | + catch (\Exception $e) |
|
89 | 89 | { |
90 | 90 | $status = 500; |
91 | - $view->errors = array( array( |
|
91 | + $view->errors = array(array( |
|
92 | 92 | 'title' => $e->getMessage(), |
93 | 93 | 'detail' => $e->getTraceAsString(), |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** admin/jsonadm/standard/template-delete |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
122 | 122 | $default = 'delete-default.php'; |
123 | 123 | |
124 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
124 | + return $view->render($view->config($tplconf, $default)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -133,39 +133,39 @@ discard block |
||
133 | 133 | * @param integer &$status Variable which contains the HTTP status afterwards |
134 | 134 | * @return string Content for response body |
135 | 135 | */ |
136 | - public function get( $body, array &$header, &$status ) |
|
136 | + public function get($body, array &$header, &$status) |
|
137 | 137 | { |
138 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
138 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
139 | 139 | $view = $this->getView(); |
140 | 140 | |
141 | 141 | try |
142 | 142 | { |
143 | - $view = $this->getItem( $view ); |
|
143 | + $view = $this->getItem($view); |
|
144 | 144 | $status = 200; |
145 | 145 | } |
146 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
146 | + catch (\Aimeos\MAdmin\Exception $e) |
|
147 | 147 | { |
148 | 148 | $status = 404; |
149 | - $view->errors = array( array( |
|
150 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
149 | + $view->errors = array(array( |
|
150 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
151 | 151 | 'detail' => $e->getTraceAsString(), |
152 | - ) ); |
|
152 | + )); |
|
153 | 153 | } |
154 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + catch (\Aimeos\MShop\Exception $e) |
|
155 | 155 | { |
156 | 156 | $status = 404; |
157 | - $view->errors = array( array( |
|
158 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
157 | + $view->errors = array(array( |
|
158 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
159 | 159 | 'detail' => $e->getTraceAsString(), |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | - catch( \Exception $e ) |
|
162 | + catch (\Exception $e) |
|
163 | 163 | { |
164 | 164 | $status = 500; |
165 | - $view->errors = array( array( |
|
165 | + $view->errors = array(array( |
|
166 | 166 | 'title' => $e->getMessage(), |
167 | 167 | 'detail' => $e->getTraceAsString(), |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** admin/jsonadm/standard/template-get |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $tplconf = 'admin/jsonadm/standard/template-get'; |
196 | 196 | $default = 'get-default.php'; |
197 | 197 | |
198 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
198 | + return $view->render($view->config($tplconf, $default)); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -207,48 +207,48 @@ discard block |
||
207 | 207 | * @param integer &$status Variable which contains the HTTP status afterwards |
208 | 208 | * @return string Content for response body |
209 | 209 | */ |
210 | - public function patch( $body, array &$header, &$status ) |
|
210 | + public function patch($body, array &$header, &$status) |
|
211 | 211 | { |
212 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
212 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
213 | 213 | $context = $this->getContext(); |
214 | 214 | $view = $this->getView(); |
215 | 215 | |
216 | 216 | try |
217 | 217 | { |
218 | - $view = $this->patchItems( $view, $body, $header ); |
|
218 | + $view = $this->patchItems($view, $body, $header); |
|
219 | 219 | $status = 200; |
220 | 220 | } |
221 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
221 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
222 | 222 | { |
223 | 223 | $status = $e->getCode(); |
224 | - $view->errors = array( array( |
|
225 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
224 | + $view->errors = array(array( |
|
225 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
226 | 226 | 'detail' => $e->getTraceAsString(), |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | } |
229 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
229 | + catch (\Aimeos\MAdmin\Exception $e) |
|
230 | 230 | { |
231 | 231 | $status = 404; |
232 | - $view->errors = array( array( |
|
233 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
232 | + $view->errors = array(array( |
|
233 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
234 | 234 | 'detail' => $e->getTraceAsString(), |
235 | - ) ); |
|
235 | + )); |
|
236 | 236 | } |
237 | - catch( \Aimeos\MShop\Exception $e ) |
|
237 | + catch (\Aimeos\MShop\Exception $e) |
|
238 | 238 | { |
239 | 239 | $status = 404; |
240 | - $view->errors = array( array( |
|
241 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
240 | + $view->errors = array(array( |
|
241 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
242 | 242 | 'detail' => $e->getTraceAsString(), |
243 | - ) ); |
|
243 | + )); |
|
244 | 244 | } |
245 | - catch( \Exception $e ) |
|
245 | + catch (\Exception $e) |
|
246 | 246 | { |
247 | 247 | $status = 500; |
248 | - $view->errors = array( array( |
|
248 | + $view->errors = array(array( |
|
249 | 249 | 'title' => $e->getMessage(), |
250 | 250 | 'detail' => $e->getTraceAsString(), |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** admin/jsonadm/standard/template-patch |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
279 | 279 | $default = 'patch-default.php'; |
280 | 280 | |
281 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
281 | + return $view->render($view->config($tplconf, $default)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -290,48 +290,48 @@ discard block |
||
290 | 290 | * @param integer &$status Variable which contains the HTTP status afterwards |
291 | 291 | * @return string Content for response body |
292 | 292 | */ |
293 | - public function post( $body, array &$header, &$status ) |
|
293 | + public function post($body, array &$header, &$status) |
|
294 | 294 | { |
295 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
295 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
296 | 296 | $context = $this->getContext(); |
297 | 297 | $view = $this->getView(); |
298 | 298 | |
299 | 299 | try |
300 | 300 | { |
301 | - $view = $this->postItems( $view, $body, $header ); |
|
301 | + $view = $this->postItems($view, $body, $header); |
|
302 | 302 | $status = 201; |
303 | 303 | } |
304 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
304 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
305 | 305 | { |
306 | 306 | $status = $e->getCode(); |
307 | - $view->errors = array( array( |
|
308 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
307 | + $view->errors = array(array( |
|
308 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
309 | 309 | 'detail' => $e->getTraceAsString(), |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | } |
312 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
312 | + catch (\Aimeos\MAdmin\Exception $e) |
|
313 | 313 | { |
314 | 314 | $status = 404; |
315 | - $view->errors = array( array( |
|
316 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
315 | + $view->errors = array(array( |
|
316 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
317 | 317 | 'detail' => $e->getTraceAsString(), |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | } |
320 | - catch( \Aimeos\MShop\Exception $e ) |
|
320 | + catch (\Aimeos\MShop\Exception $e) |
|
321 | 321 | { |
322 | 322 | $status = 404; |
323 | - $view->errors = array( array( |
|
324 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
323 | + $view->errors = array(array( |
|
324 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
325 | 325 | 'detail' => $e->getTraceAsString(), |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | } |
328 | - catch( \Exception $e ) |
|
328 | + catch (\Exception $e) |
|
329 | 329 | { |
330 | 330 | $status = 500; |
331 | - $view->errors = array( array( |
|
331 | + $view->errors = array(array( |
|
332 | 332 | 'title' => $e->getMessage(), |
333 | 333 | 'detail' => $e->getTraceAsString(), |
334 | - ) ); |
|
334 | + )); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** admin/jsonadm/standard/template-post |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $tplconf = 'admin/jsonadm/standard/template-post'; |
362 | 362 | $default = 'post-default.php'; |
363 | 363 | |
364 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
364 | + return $view->render($view->config($tplconf, $default)); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | * @param integer &$status Variable which contains the HTTP status afterwards |
374 | 374 | * @return string Content for response body |
375 | 375 | */ |
376 | - public function put( $body, array &$header, &$status ) |
|
376 | + public function put($body, array &$header, &$status) |
|
377 | 377 | { |
378 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
378 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
379 | 379 | $status = 501; |
380 | 380 | |
381 | 381 | $context = $this->getContext(); |
382 | 382 | $view = $this->getView(); |
383 | 383 | |
384 | - $view->errors = array( array( |
|
385 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
386 | - ) ); |
|
384 | + $view->errors = array(array( |
|
385 | + 'title' => $context->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
386 | + )); |
|
387 | 387 | |
388 | 388 | /** admin/jsonadm/standard/template-put |
389 | 389 | * Relative path to the JSON API template for PUT requests |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $tplconf = 'admin/jsonadm/standard/template-put'; |
413 | 413 | $default = 'put-default.php'; |
414 | 414 | |
415 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
415 | + return $view->render($view->config($tplconf, $default)); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param integer &$status Variable which contains the HTTP status afterwards |
425 | 425 | * @return string Content for response body |
426 | 426 | */ |
427 | - public function options( $body, array &$header, &$status ) |
|
427 | + public function options($body, array &$header, &$status) |
|
428 | 428 | { |
429 | 429 | $context = $this->getContext(); |
430 | 430 | $view = $this->getView(); |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | { |
434 | 434 | $resources = $attributes = array(); |
435 | 435 | |
436 | - foreach( $this->getDomains( $view ) as $domain ) |
|
436 | + foreach ($this->getDomains($view) as $domain) |
|
437 | 437 | { |
438 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
439 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
440 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
438 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
439 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
440 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $view->resources = $resources; |
@@ -449,29 +449,29 @@ discard block |
||
449 | 449 | ); |
450 | 450 | $status = 200; |
451 | 451 | } |
452 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
452 | + catch (\Aimeos\MAdmin\Exception $e) |
|
453 | 453 | { |
454 | 454 | $status = 404; |
455 | - $view->errors = array( array( |
|
456 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
455 | + $view->errors = array(array( |
|
456 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
457 | 457 | 'detail' => $e->getTraceAsString(), |
458 | - ) ); |
|
458 | + )); |
|
459 | 459 | } |
460 | - catch( \Aimeos\MShop\Exception $e ) |
|
460 | + catch (\Aimeos\MShop\Exception $e) |
|
461 | 461 | { |
462 | 462 | $status = 404; |
463 | - $view->errors = array( array( |
|
464 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
463 | + $view->errors = array(array( |
|
464 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
465 | 465 | 'detail' => $e->getTraceAsString(), |
466 | - ) ); |
|
466 | + )); |
|
467 | 467 | } |
468 | - catch( \Exception $e ) |
|
468 | + catch (\Exception $e) |
|
469 | 469 | { |
470 | 470 | $status = 500; |
471 | - $view->errors = array( array( |
|
471 | + $view->errors = array(array( |
|
472 | 472 | 'title' => $e->getMessage(), |
473 | 473 | 'detail' => $e->getTraceAsString(), |
474 | - ) ); |
|
474 | + )); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** admin/jsonadm/standard/template-options |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $tplconf = 'admin/jsonadm/standard/template-options'; |
502 | 502 | $default = 'options-default.php'; |
503 | 503 | |
504 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
504 | + return $view->render($view->config($tplconf, $default)); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -513,23 +513,23 @@ discard block |
||
513 | 513 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
514 | 514 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
515 | 515 | */ |
516 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
516 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
517 | 517 | { |
518 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
518 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
519 | 519 | |
520 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
520 | + if (($id = $view->param('id')) == null) |
|
521 | 521 | { |
522 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
523 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
522 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
523 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
524 | 524 | } |
525 | 525 | |
526 | - $ids = $this->getIds( $request ); |
|
527 | - $manager->deleteItems( $ids ); |
|
528 | - $view->total = count( $ids ); |
|
526 | + $ids = $this->getIds($request); |
|
527 | + $manager->deleteItems($ids); |
|
528 | + $view->total = count($ids); |
|
529 | 529 | } |
530 | 530 | else |
531 | 531 | { |
532 | - $manager->deleteItem( $id ); |
|
532 | + $manager->deleteItem($id); |
|
533 | 533 | $view->total = 1; |
534 | 534 | } |
535 | 535 | |
@@ -543,27 +543,27 @@ discard block |
||
543 | 543 | * @param \Aimeos\MW\View\Iface $view View instance |
544 | 544 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
545 | 545 | */ |
546 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
546 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
547 | 547 | { |
548 | 548 | $total = 1; |
549 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
550 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
549 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
550 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
551 | 551 | |
552 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
552 | + if (($id = $view->param('id')) == null) |
|
553 | 553 | { |
554 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
555 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
556 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
557 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
554 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
555 | + $view->data = $manager->searchItems($search, array(), $total); |
|
556 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
557 | + $view->listItems = $this->getListItems($view->data, $include); |
|
558 | 558 | } |
559 | 559 | else |
560 | 560 | { |
561 | - $view->data = $manager->getItem( $id, array() ); |
|
562 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
563 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
561 | + $view->data = $manager->getItem($id, array()); |
|
562 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
563 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
564 | 564 | } |
565 | 565 | |
566 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
566 | + $view->refItems = $this->getRefItems($view->listItems); |
|
567 | 567 | |
568 | 568 | $view->total = $total; |
569 | 569 | |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | * @param array $params List of criteria data with condition, sorting and paging |
589 | 589 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
590 | 590 | */ |
591 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
591 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
592 | 592 | { |
593 | - $this->initCriteriaConditions( $criteria, $params ); |
|
594 | - $this->initCriteriaSortations( $criteria, $params ); |
|
595 | - $this->initCriteriaSlice( $criteria, $params ); |
|
593 | + $this->initCriteriaConditions($criteria, $params); |
|
594 | + $this->initCriteriaSortations($criteria, $params); |
|
595 | + $this->initCriteriaSlice($criteria, $params); |
|
596 | 596 | |
597 | 597 | return $criteria; |
598 | 598 | } |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
605 | 605 | * @param array $params List of criteria data with condition, sorting and paging |
606 | 606 | */ |
607 | - private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
607 | + private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
608 | 608 | { |
609 | - if( isset( $params['filter'] ) && is_array( $params['filter'] ) ) |
|
609 | + if (isset($params['filter']) && is_array($params['filter'])) |
|
610 | 610 | { |
611 | 611 | $existing = $criteria->getConditions(); |
612 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
612 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
613 | 613 | |
614 | - $expr = array( $criteria->getConditions(), $existing ); |
|
615 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
614 | + $expr = array($criteria->getConditions(), $existing); |
|
615 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
624 | 624 | * @param array $params List of criteria data with condition, sorting and paging |
625 | 625 | */ |
626 | - private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
626 | + private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
627 | 627 | { |
628 | - $start = ( isset( $params['page']['offset'] ) ? $params['page']['offset'] : 0 ); |
|
629 | - $size = ( isset( $params['page']['limit'] ) ? $params['page']['limit'] : 25 ); |
|
628 | + $start = (isset($params['page']['offset']) ? $params['page']['offset'] : 0); |
|
629 | + $size = (isset($params['page']['limit']) ? $params['page']['limit'] : 25); |
|
630 | 630 | |
631 | - $criteria->setSlice( $start, $size ); |
|
631 | + $criteria->setSlice($start, $size); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
@@ -638,24 +638,24 @@ discard block |
||
638 | 638 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
639 | 639 | * @param array $params List of criteria data with condition, sorting and paging |
640 | 640 | */ |
641 | - private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
641 | + private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
642 | 642 | { |
643 | - if( !isset( $params['sort'] ) ) { |
|
643 | + if (!isset($params['sort'])) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
647 | 647 | $sortation = array(); |
648 | 648 | |
649 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
649 | + foreach (explode(',', $params['sort']) as $sort) |
|
650 | 650 | { |
651 | - if( $sort[0] === '-' ) { |
|
652 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
651 | + if ($sort[0] === '-') { |
|
652 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
653 | 653 | } else { |
654 | - $sortation[] = $criteria->sort( '+', $sort ); break; |
|
654 | + $sortation[] = $criteria->sort('+', $sort); break; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | - $criteria->setSortations( $sortation ); |
|
658 | + $criteria->setSortations($sortation); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -665,9 +665,9 @@ discard block |
||
665 | 665 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
666 | 666 | * @return array List of domain names |
667 | 667 | */ |
668 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
668 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
669 | 669 | { |
670 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
670 | + if (($domains = $view->param('resource')) == '') |
|
671 | 671 | { |
672 | 672 | /** admin/jsonadm/domains |
673 | 673 | * A list of domain names whose clients are available for the JSON API |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
690 | 690 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
691 | 691 | ); |
692 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
692 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | return (array) $domains; |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @param array $include List of resource types that should be fetched |
704 | 704 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
705 | 705 | */ |
706 | - protected function getChildItems( array $items, array $include ) |
|
706 | + protected function getChildItems(array $items, array $include) |
|
707 | 707 | { |
708 | 708 | return array(); |
709 | 709 | } |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param array $include List of resource types that should be fetched |
717 | 717 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
718 | 718 | */ |
719 | - protected function getListItems( array $items, array $include ) |
|
719 | + protected function getListItems(array $items, array $include) |
|
720 | 720 | { |
721 | 721 | return array(); |
722 | 722 | } |
@@ -728,22 +728,22 @@ discard block |
||
728 | 728 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
729 | 729 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
730 | 730 | */ |
731 | - protected function getRefItems( array $listItems ) |
|
731 | + protected function getRefItems(array $listItems) |
|
732 | 732 | { |
733 | 733 | $list = $map = array(); |
734 | 734 | |
735 | - foreach( $listItems as $listItem ) { |
|
735 | + foreach ($listItems as $listItem) { |
|
736 | 736 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
737 | 737 | } |
738 | 738 | |
739 | - foreach( $map as $domain => $ids ) |
|
739 | + foreach ($map as $domain => $ids) |
|
740 | 740 | { |
741 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
741 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
742 | 742 | |
743 | 743 | $search = $manager->createSearch(); |
744 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
744 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
745 | 745 | |
746 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
746 | + $list = array_merge($list, $manager->searchItems($search)); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | return $list; |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | * @param \stdClass $request Decoded request body |
757 | 757 | * @return array List of item IDs |
758 | 758 | */ |
759 | - protected function getIds( $request ) |
|
759 | + protected function getIds($request) |
|
760 | 760 | { |
761 | 761 | $ids = array(); |
762 | 762 | |
763 | - if( isset( $request->data ) ) |
|
763 | + if (isset($request->data)) |
|
764 | 764 | { |
765 | - foreach( $request->data as $entry ) |
|
765 | + foreach ($request->data as $entry) |
|
766 | 766 | { |
767 | - if( isset( $entry->id ) ) { |
|
767 | + if (isset($entry->id)) { |
|
768 | 768 | $ids[] = $entry->id; |
769 | 769 | } |
770 | 770 | } |
@@ -816,30 +816,30 @@ discard block |
||
816 | 816 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
817 | 817 | * @return \Aimeos\MW\View\Iface Updated view instance |
818 | 818 | */ |
819 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
819 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
820 | 820 | { |
821 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
822 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
821 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
822 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
823 | 823 | } |
824 | 824 | |
825 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
825 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
826 | 826 | |
827 | - if( is_array( $request->data ) ) |
|
827 | + if (is_array($request->data)) |
|
828 | 828 | { |
829 | - $data = $this->saveData( $manager, $request ); |
|
829 | + $data = $this->saveData($manager, $request); |
|
830 | 830 | |
831 | 831 | $view->data = $data; |
832 | - $view->total = count( $data ); |
|
832 | + $view->total = count($data); |
|
833 | 833 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
834 | 834 | } |
835 | 835 | else |
836 | 836 | { |
837 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
838 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
837 | + if (($id = $view->param('id')) == null) { |
|
838 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | $request->data->id = $id; |
842 | - $data = $this->saveEntry( $manager, $request->data ); |
|
842 | + $data = $this->saveEntry($manager, $request->data); |
|
843 | 843 | |
844 | 844 | $view->data = $data; |
845 | 845 | $view->total = 1; |
@@ -857,31 +857,31 @@ discard block |
||
857 | 857 | * @param array &$header Associative list of HTTP headers as value/result parameter |
858 | 858 | * @return \Aimeos\MW\View\Iface Updated view instance |
859 | 859 | */ |
860 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
860 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
861 | 861 | { |
862 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
863 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
862 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
863 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
864 | 864 | } |
865 | 865 | |
866 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
867 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
866 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
867 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | |
871 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
871 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
872 | 872 | |
873 | - if( is_array( $request->data ) ) |
|
873 | + if (is_array($request->data)) |
|
874 | 874 | { |
875 | - $data = $this->saveData( $manager, $request ); |
|
875 | + $data = $this->saveData($manager, $request); |
|
876 | 876 | |
877 | 877 | $view->data = $data; |
878 | - $view->total = count( $data ); |
|
878 | + $view->total = count($data); |
|
879 | 879 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
880 | 880 | } |
881 | 881 | else |
882 | 882 | { |
883 | 883 | $request->data->id = null; |
884 | - $data = $this->saveEntry( $manager, $request->data ); |
|
884 | + $data = $this->saveEntry($manager, $request->data); |
|
885 | 885 | |
886 | 886 | $view->data = $data; |
887 | 887 | $view->total = 1; |
@@ -898,14 +898,14 @@ discard block |
||
898 | 898 | * @param \stdClass $request Object with request body data |
899 | 899 | * @return array List of items |
900 | 900 | */ |
901 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
901 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
902 | 902 | { |
903 | 903 | $data = array(); |
904 | 904 | |
905 | - if( isset( $request->data ) ) |
|
905 | + if (isset($request->data)) |
|
906 | 906 | { |
907 | - foreach( (array) $request->data as $entry ) { |
|
908 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
907 | + foreach ((array) $request->data as $entry) { |
|
908 | + $data[] = $this->saveEntry($manager, $entry); |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
@@ -920,22 +920,22 @@ discard block |
||
920 | 920 | * @param \stdClass $entry Object including "id" and "attributes" elements |
921 | 921 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
922 | 922 | */ |
923 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
923 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
924 | 924 | { |
925 | - if( isset( $entry->id ) && $entry->id !== null ) { |
|
926 | - $item = $manager->getItem( $entry->id ); |
|
925 | + if (isset($entry->id) && $entry->id !== null) { |
|
926 | + $item = $manager->getItem($entry->id); |
|
927 | 927 | } else { |
928 | 928 | $item = $manager->createItem(); |
929 | 929 | } |
930 | 930 | |
931 | - $item = $this->addItemData( $manager, $item, $entry ); |
|
932 | - $manager->saveItem( $item ); |
|
931 | + $item = $this->addItemData($manager, $item, $entry); |
|
932 | + $manager->saveItem($item); |
|
933 | 933 | |
934 | - if( isset( $entry->relationships ) ) { |
|
935 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
934 | + if (isset($entry->relationships)) { |
|
935 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
936 | 936 | } |
937 | 937 | |
938 | - return $manager->getItem( $item->getId() ); |
|
938 | + return $manager->getItem($item->getId()); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | |
@@ -946,28 +946,28 @@ discard block |
||
946 | 946 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
947 | 947 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
948 | 948 | */ |
949 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
950 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
949 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
950 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
951 | 951 | { |
952 | 952 | $id = $item->getId(); |
953 | - $listManager = $manager->getSubManager( 'lists' ); |
|
953 | + $listManager = $manager->getSubManager('lists'); |
|
954 | 954 | |
955 | - foreach( (array) $relationships as $domain => $list ) |
|
955 | + foreach ((array) $relationships as $domain => $list) |
|
956 | 956 | { |
957 | - if( isset( $list->data ) ) |
|
957 | + if (isset($list->data)) |
|
958 | 958 | { |
959 | - foreach( (array) $list->data as $data ) |
|
959 | + foreach ((array) $list->data as $data) |
|
960 | 960 | { |
961 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
961 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
962 | 962 | |
963 | - if( isset( $data->id ) ) { |
|
964 | - $listItem->setRefId( $data->id ); |
|
963 | + if (isset($data->id)) { |
|
964 | + $listItem->setRefId($data->id); |
|
965 | 965 | } |
966 | 966 | |
967 | - $listItem->setParentId( $id ); |
|
968 | - $listItem->setDomain( $domain ); |
|
967 | + $listItem->setParentId($id); |
|
968 | + $listItem->setDomain($domain); |
|
969 | 969 | |
970 | - $listManager->saveItem( $listItem, false ); |
|
970 | + $listManager->saveItem($listItem, false); |
|
971 | 971 | } |
972 | 972 | } |
973 | 973 | } |
@@ -984,24 +984,24 @@ discard block |
||
984 | 984 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
985 | 985 | */ |
986 | 986 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
987 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain = null ) |
|
987 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain = null) |
|
988 | 988 | { |
989 | - if( isset( $data->attributes ) ) |
|
989 | + if (isset($data->attributes)) |
|
990 | 990 | { |
991 | 991 | $attr = (array) $data->attributes; |
992 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
992 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
993 | 993 | |
994 | - if( isset( $attr[$key.'.type'] ) ) |
|
994 | + if (isset($attr[$key . '.type'])) |
|
995 | 995 | { |
996 | - if( $domain === null ) { |
|
997 | - $domain = ( isset( $attr[$key.'.domain'] ) ? $attr[$key.'.domain'] : $key ); |
|
996 | + if ($domain === null) { |
|
997 | + $domain = (isset($attr[$key . '.domain']) ? $attr[$key . '.domain'] : $key); |
|
998 | 998 | } |
999 | 999 | |
1000 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
1001 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
1000 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
1001 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | - $item->fromArray( $attr ); |
|
1004 | + $item->fromArray($attr); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | return $item; |
@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,31 +27,31 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $childItems as $childItem ) |
|
35 | + foreach ($childItems as $childItem) |
|
36 | 36 | { |
37 | - if( $childItem->getParentId() == $id ) |
|
37 | + if ($childItem->getParentId() == $id) |
|
38 | 38 | { |
39 | 39 | $type = $childItem->getResourceType(); |
40 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
40 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach( $listItems as $listId => $listItem ) |
|
44 | + foreach ($listItems as $listId => $listItem) |
|
45 | 45 | { |
46 | - if( $listItem->getParentId() == $id ) |
|
46 | + if ($listItem->getParentId() == $id) |
|
47 | 47 | { |
48 | 48 | $type = $listItem->getDomain(); |
49 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
49 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
50 | 50 | |
51 | 51 | $result['relationships'][$type][] = array( |
52 | - 'data' => array( 'id' => $listItem->getRefId(), 'type' => $type, |
|
52 | + 'data' => array('id' => $listItem->getRefId(), 'type' => $type, |
|
53 | 53 | 'attributes' => $listItem->toArray(), 'links' => array( |
54 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
54 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
55 | 55 | ) |
56 | 56 | ) ); |
57 | 57 | } |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | }; |
62 | 62 | |
63 | 63 | |
64 | -$fields = $this->param( 'fields', array() ); |
|
64 | +$fields = $this->param('fields', array()); |
|
65 | 65 | |
66 | -foreach( (array) $fields as $resource => $list ) { |
|
67 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
66 | +foreach ((array) $fields as $resource => $list) { |
|
67 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | -$data = $this->get( 'data', array() ); |
|
72 | -$childItems = $this->get( 'childItems', array() ); |
|
73 | -$listItems = $this->get( 'listItems', array() ); |
|
71 | +$data = $this->get('data', array()); |
|
72 | +$childItems = $this->get('childItems', array()); |
|
73 | +$listItems = $this->get('listItems', array()); |
|
74 | 74 | |
75 | -if( is_array( $data ) ) |
|
75 | +if (is_array($data)) |
|
76 | 76 | { |
77 | 77 | $response = array(); |
78 | 78 | |
79 | - foreach( $data as $item ) { |
|
80 | - $response[] = $build( $this, $item, $fields, $childItems, $listItems ); |
|
79 | + foreach ($data as $item) { |
|
80 | + $response[] = $build($this, $item, $fields, $childItems, $listItems); |
|
81 | 81 | } |
82 | 82 | } |
83 | -elseif( $data !== null ) |
|
83 | +elseif ($data !== null) |
|
84 | 84 | { |
85 | - $response = $build( $this, $data, $fields, $childItems, $listItems ); |
|
85 | + $response = $build($this, $data, $fields, $childItems, $listItems); |
|
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
@@ -90,4 +90,4 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | -echo json_encode( $response, $options ); |
|
94 | 93 | \ No newline at end of file |
94 | +echo json_encode($response, $options); |
|
95 | 95 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJadm::getContext(); |
17 | 17 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJadm::getContext(); |
27 | 27 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
28 | 28 | |
29 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
30 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
29 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
30 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJadm::getContext(); |
37 | 37 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
38 | 38 | |
39 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
40 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
39 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
40 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $context = \TestHelperJadm::getContext(); |
47 | 47 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
50 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
50 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,68 +56,68 @@ discard block |
||
56 | 56 | $context = \TestHelperJadm::getContext(); |
57 | 57 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
58 | 58 | |
59 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
60 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
60 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testClear() |
65 | 65 | { |
66 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
66 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
67 | 67 | |
68 | 68 | $context = \TestHelperJadm::getContext(); |
69 | 69 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
70 | 70 | |
71 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
71 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
72 | 72 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
73 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
73 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
74 | 74 | |
75 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
75 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
76 | 76 | |
77 | - $this->assertNotSame( $client1, $client2 ); |
|
77 | + $this->assertNotSame($client1, $client2); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testClearSite() |
82 | 82 | { |
83 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
83 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
84 | 84 | |
85 | 85 | $context = \TestHelperJadm::getContext(); |
86 | 86 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
87 | 87 | |
88 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
89 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
90 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
88 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
89 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
90 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
91 | 91 | |
92 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
93 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
92 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
93 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
94 | 94 | |
95 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
95 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
96 | 96 | |
97 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
98 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
97 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
98 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testClearSpecific() |
103 | 103 | { |
104 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
104 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
105 | 105 | |
106 | 106 | $context = \TestHelperJadm::getContext(); |
107 | 107 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
108 | 108 | |
109 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
110 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
109 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
110 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
111 | 111 | |
112 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
112 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
113 | 113 | |
114 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
115 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
114 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
115 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
116 | 116 | |
117 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
117 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
118 | 118 | |
119 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
120 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
119 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
120 | + $this->assertSame($cntlB1, $cntlB2); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
35 | 35 | */ |
36 | - static public function clear( $id = null, $path = null ) |
|
36 | + static public function clear($id = null, $path = null) |
|
37 | 37 | { |
38 | - if( $id !== null ) |
|
38 | + if ($id !== null) |
|
39 | 39 | { |
40 | - if( $path !== null ) { |
|
40 | + if ($path !== null) { |
|
41 | 41 | self::$clients[$id][$path] = null; |
42 | 42 | } else { |
43 | 43 | self::$clients[$id] = array(); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
67 | 67 | */ |
68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
69 | - array $templatePaths, $path, $name = null ) |
|
68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
69 | + array $templatePaths, $path, $name = null) |
|
70 | 70 | { |
71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
72 | 72 | |
73 | - if( empty( $path ) ) { |
|
74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
73 | + if (empty($path)) { |
|
74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $id = (string) $context; |
78 | 78 | |
79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
91 | 91 | * @return boolean Previous cache setting |
92 | 92 | */ |
93 | - static public function setCache( $value ) |
|
93 | + static public function setCache($value) |
|
94 | 94 | { |
95 | 95 | $old = self::$cache; |
96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
111 | 111 | */ |
112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
113 | - array $templatePaths, $path, $name ) |
|
112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
113 | + array $templatePaths, $path, $name) |
|
114 | 114 | { |
115 | - $parts = explode( '/', $path ); |
|
115 | + $parts = explode('/', $path); |
|
116 | 116 | |
117 | - foreach( $parts as $key => $part ) |
|
117 | + foreach ($parts as $key => $part) |
|
118 | 118 | { |
119 | - if( ctype_alnum( $part ) === false ) |
|
119 | + if (ctype_alnum($part) === false) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
123 | 123 | } |
124 | 124 | |
125 | - $parts[$key] = ucwords( $part ); |
|
125 | + $parts[$key] = ucwords($part); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | $view = $context->getView(); |
130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
131 | 131 | |
132 | - if( class_exists( $factory ) === true ) |
|
132 | + if (class_exists($factory) === true) |
|
133 | 133 | { |
134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
135 | 135 | |
136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
159 | 159 | */ |
160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
162 | 162 | { |
163 | 163 | /** admin/jsonadm/name |
164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @since 2015.12 |
194 | 194 | * @category Developer |
195 | 195 | */ |
196 | - if( $name === null ) { |
|
197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
196 | + if ($name === null) { |
|
197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if( ctype_alnum( $name ) === false ) |
|
200 | + if (ctype_alnum($name) === false) |
|
201 | 201 | { |
202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
208 | 208 | |
209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
210 | 210 | |
211 | 211 | /** admin/jsonadm/decorators/excludes |
212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
286 | 286 | * @see admin/jsonadm/decorators/global |
287 | 287 | */ |
288 | 288 | |
289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
290 | 290 | } |
291 | 291 | } |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
137 | 137 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
138 | 138 | } |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
143 | 142 | } |
@@ -19,77 +19,77 @@ discard block |
||
19 | 19 | $this->context = \TestHelperJadm::getContext(); |
20 | 20 | $config = $this->context->getConfig(); |
21 | 21 | |
22 | - $config->set( 'admin/jsonadm/common/decorators/default', array() ); |
|
23 | - $config->set( 'admin/jsonadm/decorators/global', array() ); |
|
24 | - $config->set( 'admin/jsonadm/decorators/local', array() ); |
|
22 | + $config->set('admin/jsonadm/common/decorators/default', array()); |
|
23 | + $config->set('admin/jsonadm/decorators/global', array()); |
|
24 | + $config->set('admin/jsonadm/decorators/local', array()); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testInjectClient() |
30 | 30 | { |
31 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
32 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
31 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
32 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
33 | 33 | |
34 | - $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
34 | + $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
35 | 35 | |
36 | - $this->assertSame( $cntl, $iCntl ); |
|
36 | + $this->assertSame($cntl, $iCntl); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testInjectClientReset() |
41 | 41 | { |
42 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
43 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
44 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', null ); |
|
42 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
43 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
44 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', null); |
|
45 | 45 | |
46 | - $new = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
46 | + $new = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
47 | 47 | |
48 | - $this->assertNotSame( $cntl, $new ); |
|
48 | + $this->assertNotSame($cntl, $new); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testAddDecoratorsInvalidName() |
53 | 53 | { |
54 | - $decorators = array( '$' ); |
|
54 | + $decorators = array('$'); |
|
55 | 55 | $view = $this->context->getView(); |
56 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
56 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
57 | 57 | |
58 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
59 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute' ); |
|
58 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
59 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testAddDecoratorsInvalidClass() |
64 | 64 | { |
65 | - $decorators = array( 'Test' ); |
|
65 | + $decorators = array('Test'); |
|
66 | 66 | $view = $this->context->getView(); |
67 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
67 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
68 | 68 | |
69 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
70 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute' ); |
|
69 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
70 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testAddDecoratorsInvalidInterface() |
75 | 75 | { |
76 | - $decorators = array( 'Test' ); |
|
76 | + $decorators = array('Test'); |
|
77 | 77 | $view = $this->context->getView(); |
78 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
78 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
79 | 79 | |
80 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
81 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, |
|
82 | - '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute' ); |
|
80 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
81 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, |
|
82 | + '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testAddClientDecoratorsExcludes() |
87 | 87 | { |
88 | - $this->context->getConfig()->set( 'admin/jsonadm/decorators/excludes', array( 'TestDecorator' ) ); |
|
89 | - $this->context->getConfig()->set( 'admin/jsonadm/common/decorators/default', array( 'TestDecorator' ) ); |
|
88 | + $this->context->getConfig()->set('admin/jsonadm/decorators/excludes', array('TestDecorator')); |
|
89 | + $this->context->getConfig()->set('admin/jsonadm/common/decorators/default', array('TestDecorator')); |
|
90 | 90 | |
91 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
92 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
91 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
92 | + \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param string $classprefix |
102 | 102 | * @param string $path |
103 | 103 | */ |
104 | - public static function addDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
104 | + public static function addDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
106 | 106 | { |
107 | - self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
107 | + self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function addClientDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
110 | + public static function addClientDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
112 | 112 | { |
113 | - self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
113 | + self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 |
@@ -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\Product\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,34 +30,34 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'product.code' => 'CNE' ) |
|
33 | + '==' => array('product.code' => 'CNE') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text,product,product/property,product/stock' |
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 ); |
|
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( 'product', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['text'][0]['data']['links'] ); |
|
52 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
53 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['product'][0]['data']['links'] ); |
|
54 | - $this->assertEquals( 4, count( $result['data'][0]['relationships']['product/property'] ) ); |
|
55 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['product/stock'] ) ); |
|
56 | - $this->assertEquals( 15, count( $result['included'] ) ); |
|
57 | - $this->assertEquals( 'product/property', $result['included'][0]['type'] ); |
|
58 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
59 | - $this->assertArrayHaskey( 'related', $result['included'][0]['links'] ); |
|
60 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
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('product', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['text'][0]['data']['links']); |
|
52 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
53 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['product'][0]['data']['links']); |
|
54 | + $this->assertEquals(4, count($result['data'][0]['relationships']['product/property'])); |
|
55 | + $this->assertEquals(1, count($result['data'][0]['relationships']['product/stock'])); |
|
56 | + $this->assertEquals(15, count($result['included'])); |
|
57 | + $this->assertEquals('product/property', $result['included'][0]['type']); |
|
58 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
59 | + $this->assertArrayHaskey('related', $result['included'][0]['links']); |
|
60 | + $this->assertArrayNotHasKey('errors', $result); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | 'sort' => 'product.id', |
71 | 71 | 'include' => 'product,product/stock' |
72 | 72 | ); |
73 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
74 | - $this->view->addHelper( 'param', $helper ); |
|
73 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
74 | + $this->view->addHelper('param', $helper); |
|
75 | 75 | |
76 | 76 | $header = array(); |
77 | 77 | $status = 500; |
78 | 78 | |
79 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
80 | - |
|
81 | - $this->assertEquals( 200, $status ); |
|
82 | - $this->assertEquals( 1, count( $header ) ); |
|
83 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
84 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
85 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
86 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
87 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
88 | - $this->assertEquals( 27, count( $result['included'] ) ); |
|
89 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
79 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
80 | + |
|
81 | + $this->assertEquals(200, $status); |
|
82 | + $this->assertEquals(1, count($header)); |
|
83 | + $this->assertEquals(28, $result['meta']['total']); |
|
84 | + $this->assertEquals(25, count($result['data'])); |
|
85 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
86 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
87 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
88 | + $this->assertEquals(27, count($result['included'])); |
|
89 | + $this->assertArrayNotHasKey('errors', $result); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -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\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,42 +34,42 @@ discard block |
||
34 | 34 | |
35 | 35 | public function testDelete() |
36 | 36 | { |
37 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ); |
|
37 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem'); |
|
38 | 38 | |
39 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
40 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
41 | - $this->view->addHelper( 'param', $helper ); |
|
39 | + $params = array('id' => $this->getProductItem()->getId()); |
|
40 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
41 | + $this->view->addHelper('param', $helper); |
|
42 | 42 | |
43 | 43 | $header = array(); |
44 | 44 | $status = 500; |
45 | 45 | |
46 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
46 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
47 | 47 | |
48 | - $this->assertEquals( 200, $status ); |
|
49 | - $this->assertEquals( 1, count( $header ) ); |
|
50 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
51 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
52 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
48 | + $this->assertEquals(200, $status); |
|
49 | + $this->assertEquals(1, count($header)); |
|
50 | + $this->assertEquals(1, $result['meta']['total']); |
|
51 | + $this->assertArrayNotHasKey('included', $result); |
|
52 | + $this->assertArrayNotHasKey('data', $result); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testDeleteBulk() |
58 | 58 | { |
59 | - $this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' ); |
|
59 | + $this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems'); |
|
60 | 60 | |
61 | 61 | $body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}'; |
62 | 62 | $header = array(); |
63 | 63 | $status = 500; |
64 | 64 | |
65 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
65 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
66 | 66 | |
67 | - $this->assertEquals( 200, $status ); |
|
68 | - $this->assertEquals( 1, count( $header ) ); |
|
69 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
70 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
71 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
72 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
67 | + $this->assertEquals(200, $status); |
|
68 | + $this->assertEquals(1, count($header)); |
|
69 | + $this->assertEquals(2, $result['meta']['total']); |
|
70 | + $this->assertArrayNotHasKey('included', $result); |
|
71 | + $this->assertArrayNotHasKey('data', $result); |
|
72 | + $this->assertArrayNotHasKey('errors', $result); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -79,71 +79,71 @@ discard block |
||
79 | 79 | $header = array(); |
80 | 80 | $status = 500; |
81 | 81 | |
82 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
82 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
83 | 83 | |
84 | - $this->assertEquals( 400, $status ); |
|
85 | - $this->assertEquals( 1, count( $header ) ); |
|
86 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
87 | - $this->assertArrayHasKey( 'errors', $result ); |
|
88 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
89 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
84 | + $this->assertEquals(400, $status); |
|
85 | + $this->assertEquals(1, count($header)); |
|
86 | + $this->assertEquals(0, $result['meta']['total']); |
|
87 | + $this->assertArrayHasKey('errors', $result); |
|
88 | + $this->assertArrayNotHasKey('included', $result); |
|
89 | + $this->assertArrayNotHasKey('data', $result); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testDeleteException() |
94 | 94 | { |
95 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
96 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
95 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
96 | + ->will($this->throwException(new \Exception('test exception'))); |
|
97 | 97 | |
98 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
99 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
100 | - $this->view->addHelper( 'param', $helper ); |
|
98 | + $params = array('id' => $this->getProductItem()->getId()); |
|
99 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
100 | + $this->view->addHelper('param', $helper); |
|
101 | 101 | |
102 | 102 | $header = array(); |
103 | 103 | $status = 500; |
104 | 104 | |
105 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
105 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
106 | 106 | |
107 | - $this->assertEquals( 500, $status ); |
|
108 | - $this->assertArrayHasKey( 'errors', $result ); |
|
107 | + $this->assertEquals(500, $status); |
|
108 | + $this->assertArrayHasKey('errors', $result); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | 112 | public function testDeleteMAdminException() |
113 | 113 | { |
114 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
115 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
114 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
115 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
116 | 116 | |
117 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
118 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
119 | - $this->view->addHelper( 'param', $helper ); |
|
117 | + $params = array('id' => $this->getProductItem()->getId()); |
|
118 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
119 | + $this->view->addHelper('param', $helper); |
|
120 | 120 | |
121 | 121 | $header = array(); |
122 | 122 | $status = 500; |
123 | 123 | |
124 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
124 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
125 | 125 | |
126 | - $this->assertEquals( 404, $status ); |
|
127 | - $this->assertArrayHasKey( 'errors', $result ); |
|
126 | + $this->assertEquals(404, $status); |
|
127 | + $this->assertArrayHasKey('errors', $result); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testDeleteMShopException() |
132 | 132 | { |
133 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
134 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
133 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
134 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
135 | 135 | |
136 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
137 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
138 | - $this->view->addHelper( 'param', $helper ); |
|
136 | + $params = array('id' => $this->getProductItem()->getId()); |
|
137 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
138 | + $this->view->addHelper('param', $helper); |
|
139 | 139 | |
140 | 140 | $header = array(); |
141 | 141 | $status = 500; |
142 | 142 | |
143 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
143 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
144 | 144 | |
145 | - $this->assertEquals( 404, $status ); |
|
146 | - $this->assertArrayHasKey( 'errors', $result ); |
|
145 | + $this->assertEquals(404, $status); |
|
146 | + $this->assertArrayHasKey('errors', $result); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | $header = array(); |
153 | 153 | $status = 500; |
154 | 154 | |
155 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
155 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
156 | 156 | |
157 | - $this->assertEquals( 200, $status ); |
|
158 | - $this->assertEquals( 1, count( $header ) ); |
|
159 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
160 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
161 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
162 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
163 | - $this->assertArrayHasKey( 'next', $result['links'] ); |
|
164 | - $this->assertArrayHasKey( 'last', $result['links'] ); |
|
165 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
166 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
157 | + $this->assertEquals(200, $status); |
|
158 | + $this->assertEquals(1, count($header)); |
|
159 | + $this->assertEquals(28, $result['meta']['total']); |
|
160 | + $this->assertEquals(25, count($result['data'])); |
|
161 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
162 | + $this->assertEquals(0, count($result['included'])); |
|
163 | + $this->assertArrayHasKey('next', $result['links']); |
|
164 | + $this->assertArrayHasKey('last', $result['links']); |
|
165 | + $this->assertArrayHasKey('self', $result['links']); |
|
166 | + $this->assertArrayNotHasKey('errors', $result); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | $status = 500; |
174 | 174 | |
175 | 175 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
176 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/stock/warehouse' ); |
|
176 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/stock/warehouse'); |
|
177 | 177 | |
178 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
178 | + $result = json_decode($object->get('', $header, $status), true); |
|
179 | 179 | |
180 | - $this->assertEquals( 200, $status ); |
|
181 | - $this->assertEquals( 1, count( $header ) ); |
|
182 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
183 | - $this->assertEquals( 6, count( $result['data'] ) ); |
|
184 | - $this->assertEquals( 'product/stock/warehouse', $result['data'][0]['type'] ); |
|
185 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
186 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
180 | + $this->assertEquals(200, $status); |
|
181 | + $this->assertEquals(1, count($header)); |
|
182 | + $this->assertEquals(6, $result['meta']['total']); |
|
183 | + $this->assertEquals(6, count($result['data'])); |
|
184 | + $this->assertEquals('product/stock/warehouse', $result['data'][0]['type']); |
|
185 | + $this->assertEquals(0, count($result['included'])); |
|
186 | + $this->assertArrayNotHasKey('errors', $result); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -193,74 +193,74 @@ discard block |
||
193 | 193 | $status = 500; |
194 | 194 | |
195 | 195 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
196 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' ); |
|
196 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid'); |
|
197 | 197 | |
198 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
198 | + $result = json_decode($object->get('', $header, $status), true); |
|
199 | 199 | |
200 | - $this->assertEquals( 404, $status ); |
|
201 | - $this->assertEquals( 1, count( $header ) ); |
|
202 | - $this->assertEquals( 1, count( $result['errors'] ) ); |
|
203 | - $this->assertArrayHasKey( 'title', $result['errors'][0] ); |
|
204 | - $this->assertArrayHasKey( 'detail', $result['errors'][0] ); |
|
205 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
206 | - $this->assertArrayNotHasKey( 'indluded', $result ); |
|
200 | + $this->assertEquals(404, $status); |
|
201 | + $this->assertEquals(1, count($header)); |
|
202 | + $this->assertEquals(1, count($result['errors'])); |
|
203 | + $this->assertArrayHasKey('title', $result['errors'][0]); |
|
204 | + $this->assertArrayHasKey('detail', $result['errors'][0]); |
|
205 | + $this->assertArrayNotHasKey('data', $result); |
|
206 | + $this->assertArrayNotHasKey('indluded', $result); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
210 | 210 | public function testGetException() |
211 | 211 | { |
212 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
213 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
212 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
213 | + ->will($this->throwException(new \Exception('test exception'))); |
|
214 | 214 | |
215 | - $params = array( 'id' => -1 ); |
|
216 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
217 | - $this->view->addHelper( 'param', $helper ); |
|
215 | + $params = array('id' => -1); |
|
216 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
217 | + $this->view->addHelper('param', $helper); |
|
218 | 218 | |
219 | 219 | $header = array(); |
220 | 220 | $status = 500; |
221 | 221 | |
222 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
222 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
223 | 223 | |
224 | - $this->assertEquals( 500, $status ); |
|
225 | - $this->assertArrayHasKey( 'errors', $result ); |
|
224 | + $this->assertEquals(500, $status); |
|
225 | + $this->assertArrayHasKey('errors', $result); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
229 | 229 | public function testGetMAdminException() |
230 | 230 | { |
231 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
232 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
231 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
232 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
233 | 233 | |
234 | - $params = array( 'id' => -1 ); |
|
235 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
236 | - $this->view->addHelper( 'param', $helper ); |
|
234 | + $params = array('id' => -1); |
|
235 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
236 | + $this->view->addHelper('param', $helper); |
|
237 | 237 | |
238 | 238 | $header = array(); |
239 | 239 | $status = 500; |
240 | 240 | |
241 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
241 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
242 | 242 | |
243 | - $this->assertEquals( 404, $status ); |
|
244 | - $this->assertArrayHasKey( 'errors', $result ); |
|
243 | + $this->assertEquals(404, $status); |
|
244 | + $this->assertArrayHasKey('errors', $result); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | 248 | public function testGetMShopException() |
249 | 249 | { |
250 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
251 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
250 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
251 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
252 | 252 | |
253 | - $params = array( 'id' => -1 ); |
|
254 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
255 | - $this->view->addHelper( 'param', $helper ); |
|
253 | + $params = array('id' => -1); |
|
254 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
255 | + $this->view->addHelper('param', $helper); |
|
256 | 256 | |
257 | 257 | $header = array(); |
258 | 258 | $status = 500; |
259 | 259 | |
260 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
260 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
261 | 261 | |
262 | - $this->assertEquals( 404, $status ); |
|
263 | - $this->assertArrayHasKey( 'errors', $result ); |
|
262 | + $this->assertEquals(404, $status); |
|
263 | + $this->assertArrayHasKey('errors', $result); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | { |
269 | 269 | $params = array( |
270 | 270 | 'filter' => array( |
271 | - '==' => array( 'product.type.code' => 'select' ) |
|
271 | + '==' => array('product.type.code' => 'select') |
|
272 | 272 | ) |
273 | 273 | ); |
274 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
275 | - $this->view->addHelper( 'param', $helper ); |
|
274 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
275 | + $this->view->addHelper('param', $helper); |
|
276 | 276 | |
277 | 277 | $header = array(); |
278 | 278 | $status = 500; |
279 | 279 | |
280 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
280 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
281 | 281 | |
282 | - $this->assertEquals( 200, $status ); |
|
283 | - $this->assertEquals( 1, count( $header ) ); |
|
284 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
285 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
286 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
287 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
288 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
282 | + $this->assertEquals(200, $status); |
|
283 | + $this->assertEquals(1, count($header)); |
|
284 | + $this->assertEquals(3, $result['meta']['total']); |
|
285 | + $this->assertEquals(3, count($result['data'])); |
|
286 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
287 | + $this->assertEquals(0, count($result['included'])); |
|
288 | + $this->assertArrayNotHasKey('errors', $result); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -294,26 +294,26 @@ discard block |
||
294 | 294 | $params = array( |
295 | 295 | 'filter' => array( |
296 | 296 | '&&' => array( |
297 | - array( '=~' => array( 'product.label' => 'Unittest: Test' ) ), |
|
298 | - array( '==' => array( 'product.type.code' => 'select' ) ), |
|
297 | + array('=~' => array('product.label' => 'Unittest: Test')), |
|
298 | + array('==' => array('product.type.code' => 'select')), |
|
299 | 299 | ) |
300 | 300 | ) |
301 | 301 | ); |
302 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
303 | - $this->view->addHelper( 'param', $helper ); |
|
302 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
303 | + $this->view->addHelper('param', $helper); |
|
304 | 304 | |
305 | 305 | $header = array(); |
306 | 306 | $status = 500; |
307 | 307 | |
308 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
308 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
309 | 309 | |
310 | - $this->assertEquals( 200, $status ); |
|
311 | - $this->assertEquals( 1, count( $header ) ); |
|
312 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
313 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
314 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
315 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
316 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
310 | + $this->assertEquals(200, $status); |
|
311 | + $this->assertEquals(1, count($header)); |
|
312 | + $this->assertEquals(2, $result['meta']['total']); |
|
313 | + $this->assertEquals(2, count($result['data'])); |
|
314 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
315 | + $this->assertEquals(0, count($result['included'])); |
|
316 | + $this->assertArrayNotHasKey('errors', $result); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | 'limit' => 25 |
326 | 326 | ) |
327 | 327 | ); |
328 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
329 | - $this->view->addHelper( 'param', $helper ); |
|
328 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
329 | + $this->view->addHelper('param', $helper); |
|
330 | 330 | |
331 | 331 | $header = array(); |
332 | 332 | $status = 500; |
333 | 333 | |
334 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
334 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
335 | 335 | |
336 | - $this->assertEquals( 200, $status ); |
|
337 | - $this->assertEquals( 1, count( $header ) ); |
|
338 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
339 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
340 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
341 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
342 | - $this->assertArrayHasKey( 'first', $result['links'] ); |
|
343 | - $this->assertArrayHasKey( 'prev', $result['links'] ); |
|
344 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
345 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
336 | + $this->assertEquals(200, $status); |
|
337 | + $this->assertEquals(1, count($header)); |
|
338 | + $this->assertEquals(28, $result['meta']['total']); |
|
339 | + $this->assertEquals(3, count($result['data'])); |
|
340 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
341 | + $this->assertEquals(0, count($result['included'])); |
|
342 | + $this->assertArrayHasKey('first', $result['links']); |
|
343 | + $this->assertArrayHasKey('prev', $result['links']); |
|
344 | + $this->assertArrayHasKey('self', $result['links']); |
|
345 | + $this->assertArrayNotHasKey('errors', $result); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | $params = array( |
352 | 352 | 'sort' => 'product.label,-product.code' |
353 | 353 | ); |
354 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
355 | - $this->view->addHelper( 'param', $helper ); |
|
354 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
355 | + $this->view->addHelper('param', $helper); |
|
356 | 356 | |
357 | 357 | $header = array(); |
358 | 358 | $status = 500; |
359 | 359 | |
360 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
360 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
361 | 361 | |
362 | - $this->assertEquals( 200, $status ); |
|
363 | - $this->assertEquals( 1, count( $header ) ); |
|
364 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
365 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
366 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
367 | - $this->assertEquals( 'ABCD', $result['data'][0]['attributes']['product.code'] ); |
|
368 | - $this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] ); |
|
369 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
370 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
362 | + $this->assertEquals(200, $status); |
|
363 | + $this->assertEquals(1, count($header)); |
|
364 | + $this->assertEquals(28, $result['meta']['total']); |
|
365 | + $this->assertEquals(25, count($result['data'])); |
|
366 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
367 | + $this->assertEquals('ABCD', $result['data'][0]['attributes']['product.code']); |
|
368 | + $this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']); |
|
369 | + $this->assertEquals(0, count($result['included'])); |
|
370 | + $this->assertArrayNotHasKey('errors', $result); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -380,88 +380,88 @@ discard block |
||
380 | 380 | 'sort' => 'product.id', |
381 | 381 | 'include' => 'product' |
382 | 382 | ); |
383 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
384 | - $this->view->addHelper( 'param', $helper ); |
|
383 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
384 | + $this->view->addHelper('param', $helper); |
|
385 | 385 | |
386 | 386 | $header = array(); |
387 | 387 | $status = 500; |
388 | 388 | |
389 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
389 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
390 | 390 | |
391 | - $this->assertEquals( 200, $status ); |
|
392 | - $this->assertEquals( 1, count( $header ) ); |
|
393 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
394 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
395 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
396 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
397 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
391 | + $this->assertEquals(200, $status); |
|
392 | + $this->assertEquals(1, count($header)); |
|
393 | + $this->assertEquals(28, $result['meta']['total']); |
|
394 | + $this->assertEquals(25, count($result['data'])); |
|
395 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
396 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
397 | + $this->assertArrayNotHasKey('errors', $result); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
401 | 401 | public function testPatch() |
402 | 402 | { |
403 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
403 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
404 | 404 | |
405 | 405 | $item = $productManagerStub->createItem(); |
406 | - $item->setLabel( 'test' ); |
|
407 | - $item->setId( '-1' ); |
|
406 | + $item->setLabel('test'); |
|
407 | + $item->setId('-1'); |
|
408 | 408 | |
409 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
410 | - $productManagerStub->expects( $this->exactly( 3 ) )->method( 'getItem' ) // 3x due to decorator |
|
411 | - ->will( $this->returnValue( $item ) ); |
|
409 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
410 | + $productManagerStub->expects($this->exactly(3))->method('getItem') // 3x due to decorator |
|
411 | + ->will($this->returnValue($item)); |
|
412 | 412 | |
413 | 413 | |
414 | - $params = array( 'id' => '-1' ); |
|
415 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
416 | - $this->view->addHelper( 'param', $helper ); |
|
414 | + $params = array('id' => '-1'); |
|
415 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
416 | + $this->view->addHelper('param', $helper); |
|
417 | 417 | |
418 | 418 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
419 | 419 | $header = array(); |
420 | 420 | $status = 500; |
421 | 421 | |
422 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
422 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
423 | 423 | |
424 | - $this->assertEquals( 200, $status ); |
|
425 | - $this->assertEquals( 1, count( $header ) ); |
|
426 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
427 | - $this->assertArrayHasKey( 'data', $result ); |
|
428 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
429 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
430 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
431 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
432 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
424 | + $this->assertEquals(200, $status); |
|
425 | + $this->assertEquals(1, count($header)); |
|
426 | + $this->assertEquals(1, $result['meta']['total']); |
|
427 | + $this->assertArrayHasKey('data', $result); |
|
428 | + $this->assertEquals('-1', $result['data']['id']); |
|
429 | + $this->assertEquals('product', $result['data']['type']); |
|
430 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
431 | + $this->assertArrayNotHasKey('included', $result); |
|
432 | + $this->assertArrayNotHasKey('errors', $result); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
436 | 436 | public function testPatchBulk() |
437 | 437 | { |
438 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
438 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
439 | 439 | |
440 | 440 | $item = $productManagerStub->createItem(); |
441 | - $item->setLabel( 'test' ); |
|
442 | - $item->setId( '-1' ); |
|
441 | + $item->setLabel('test'); |
|
442 | + $item->setId('-1'); |
|
443 | 443 | |
444 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
445 | - $productManagerStub->expects( $this->exactly( 6 ) )->method( 'getItem' ) // 6x due to decorator |
|
446 | - ->will( $this->returnValue( $item ) ); |
|
444 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
445 | + $productManagerStub->expects($this->exactly(6))->method('getItem') // 6x due to decorator |
|
446 | + ->will($this->returnValue($item)); |
|
447 | 447 | |
448 | 448 | |
449 | 449 | $body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
450 | 450 | $header = array(); |
451 | 451 | $status = 500; |
452 | 452 | |
453 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
453 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
454 | 454 | |
455 | - $this->assertEquals( 200, $status ); |
|
456 | - $this->assertEquals( 1, count( $header ) ); |
|
457 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
458 | - $this->assertArrayHasKey( 'data', $result ); |
|
459 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
460 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
461 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
462 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
463 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
464 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
455 | + $this->assertEquals(200, $status); |
|
456 | + $this->assertEquals(1, count($header)); |
|
457 | + $this->assertEquals(2, $result['meta']['total']); |
|
458 | + $this->assertArrayHasKey('data', $result); |
|
459 | + $this->assertEquals(2, count($result['data'])); |
|
460 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
461 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
462 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
463 | + $this->assertArrayNotHasKey('included', $result); |
|
464 | + $this->assertArrayNotHasKey('errors', $result); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | $header = array(); |
472 | 472 | $status = 500; |
473 | 473 | |
474 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
474 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
475 | 475 | |
476 | - $this->assertEquals( 400, $status ); |
|
477 | - $this->assertEquals( 1, count( $header ) ); |
|
478 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
479 | - $this->assertArrayHasKey( 'errors', $result ); |
|
480 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
481 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
476 | + $this->assertEquals(400, $status); |
|
477 | + $this->assertEquals(1, count($header)); |
|
478 | + $this->assertEquals(0, $result['meta']['total']); |
|
479 | + $this->assertArrayHasKey('errors', $result); |
|
480 | + $this->assertArrayNotHasKey('included', $result); |
|
481 | + $this->assertArrayNotHasKey('data', $result); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -488,142 +488,142 @@ discard block |
||
488 | 488 | $header = array(); |
489 | 489 | $status = 500; |
490 | 490 | |
491 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
491 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
492 | 492 | |
493 | - $this->assertEquals( 400, $status ); |
|
494 | - $this->assertEquals( 1, count( $header ) ); |
|
495 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
496 | - $this->assertArrayHasKey( 'errors', $result ); |
|
493 | + $this->assertEquals(400, $status); |
|
494 | + $this->assertEquals(1, count($header)); |
|
495 | + $this->assertEquals(0, $result['meta']['total']); |
|
496 | + $this->assertArrayHasKey('errors', $result); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
500 | 500 | public function testPatchException() |
501 | 501 | { |
502 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
503 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
502 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
503 | + ->will($this->throwException(new \Exception('test exception'))); |
|
504 | 504 | |
505 | 505 | $header = array(); |
506 | 506 | $status = 500; |
507 | 507 | |
508 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
508 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
509 | 509 | |
510 | - $this->assertEquals( 500, $status ); |
|
511 | - $this->assertArrayHasKey( 'errors', $result ); |
|
510 | + $this->assertEquals(500, $status); |
|
511 | + $this->assertArrayHasKey('errors', $result); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | 515 | public function testPatchMAdminException() |
516 | 516 | { |
517 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
518 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
517 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
518 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
519 | 519 | |
520 | 520 | $header = array(); |
521 | 521 | $status = 500; |
522 | 522 | |
523 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
523 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
524 | 524 | |
525 | - $this->assertEquals( 404, $status ); |
|
526 | - $this->assertArrayHasKey( 'errors', $result ); |
|
525 | + $this->assertEquals(404, $status); |
|
526 | + $this->assertArrayHasKey('errors', $result); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | |
530 | 530 | public function testPatchMShopException() |
531 | 531 | { |
532 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
533 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
532 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
533 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
534 | 534 | |
535 | 535 | $header = array(); |
536 | 536 | $status = 500; |
537 | 537 | |
538 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
538 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
539 | 539 | |
540 | - $this->assertEquals( 404, $status ); |
|
541 | - $this->assertArrayHasKey( 'errors', $result ); |
|
540 | + $this->assertEquals(404, $status); |
|
541 | + $this->assertArrayHasKey('errors', $result); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | |
545 | 545 | public function testPost() |
546 | 546 | { |
547 | - $productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) ); |
|
547 | + $productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem')); |
|
548 | 548 | |
549 | 549 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
550 | - $item->setId( '-1' ); |
|
550 | + $item->setId('-1'); |
|
551 | 551 | |
552 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
553 | - ->will( $this->returnValue( $item ) ); |
|
554 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
555 | - ->will( $this->returnValue( $item ) ); |
|
556 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
552 | + $productManagerStub->expects($this->once())->method('createItem') |
|
553 | + ->will($this->returnValue($item)); |
|
554 | + $productManagerStub->expects($this->any())->method('getItem') |
|
555 | + ->will($this->returnValue($item)); |
|
556 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
557 | 557 | |
558 | 558 | |
559 | 559 | $body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}'; |
560 | 560 | $header = array(); |
561 | 561 | $status = 500; |
562 | 562 | |
563 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
563 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
564 | 564 | |
565 | - $this->assertEquals( 201, $status ); |
|
566 | - $this->assertEquals( 1, count( $header ) ); |
|
567 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
568 | - $this->assertArrayHasKey( 'data', $result ); |
|
569 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
570 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
571 | - $this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] ); |
|
572 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
573 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
574 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
565 | + $this->assertEquals(201, $status); |
|
566 | + $this->assertEquals(1, count($header)); |
|
567 | + $this->assertEquals(1, $result['meta']['total']); |
|
568 | + $this->assertArrayHasKey('data', $result); |
|
569 | + $this->assertEquals('-1', $result['data']['id']); |
|
570 | + $this->assertEquals('product', $result['data']['type']); |
|
571 | + $this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']); |
|
572 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
573 | + $this->assertArrayNotHasKey('included', $result); |
|
574 | + $this->assertArrayNotHasKey('errors', $result); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
578 | 578 | public function testPostBulk() |
579 | 579 | { |
580 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
580 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
581 | 581 | |
582 | 582 | $item = $productManagerStub->createItem(); |
583 | - $item->setLabel( 'test' ); |
|
584 | - $item->setId( '-1' ); |
|
583 | + $item->setLabel('test'); |
|
584 | + $item->setId('-1'); |
|
585 | 585 | |
586 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
587 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
|
588 | - ->will( $this->returnValue( $item ) ); |
|
586 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
587 | + $productManagerStub->expects($this->exactly(2))->method('getItem') |
|
588 | + ->will($this->returnValue($item)); |
|
589 | 589 | |
590 | 590 | |
591 | 591 | $body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
592 | 592 | $header = array(); |
593 | 593 | $status = 500; |
594 | 594 | |
595 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
595 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
596 | 596 | |
597 | - $this->assertEquals( 201, $status ); |
|
598 | - $this->assertEquals( 1, count( $header ) ); |
|
599 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
600 | - $this->assertArrayHasKey( 'data', $result ); |
|
601 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
602 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
603 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
604 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
605 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
606 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
597 | + $this->assertEquals(201, $status); |
|
598 | + $this->assertEquals(1, count($header)); |
|
599 | + $this->assertEquals(2, $result['meta']['total']); |
|
600 | + $this->assertArrayHasKey('data', $result); |
|
601 | + $this->assertEquals(2, count($result['data'])); |
|
602 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
603 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
604 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
605 | + $this->assertArrayNotHasKey('included', $result); |
|
606 | + $this->assertArrayNotHasKey('errors', $result); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | |
610 | 610 | public function testPostRelationships() |
611 | 611 | { |
612 | - $productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) ); |
|
613 | - $productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) ); |
|
612 | + $productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem')); |
|
613 | + $productManagerListsStub = $this->getProductListsMock(array('saveItem')); |
|
614 | 614 | |
615 | 615 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
616 | - $item->setId( '-1' ); |
|
616 | + $item->setId('-1'); |
|
617 | 617 | |
618 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
619 | - ->will( $this->returnValue( $item ) ); |
|
620 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
621 | - ->will( $this->returnValue( $item ) ); |
|
622 | - $productManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
623 | - ->will( $this->returnValue( $productManagerListsStub ) ); |
|
624 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
618 | + $productManagerStub->expects($this->once())->method('createItem') |
|
619 | + ->will($this->returnValue($item)); |
|
620 | + $productManagerStub->expects($this->any())->method('getItem') |
|
621 | + ->will($this->returnValue($item)); |
|
622 | + $productManagerStub->expects($this->once())->method('getSubManager') |
|
623 | + ->will($this->returnValue($productManagerListsStub)); |
|
624 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
625 | 625 | |
626 | - $productManagerListsStub->expects( $this->once() )->method( 'saveItem' ); |
|
626 | + $productManagerListsStub->expects($this->once())->method('saveItem'); |
|
627 | 627 | |
628 | 628 | $body = '{"data": {"type": "product", |
629 | 629 | "attributes": {"product.label": "test"}, |
@@ -634,17 +634,17 @@ discard block |
||
634 | 634 | $header = array(); |
635 | 635 | $status = 500; |
636 | 636 | |
637 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
637 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
638 | 638 | |
639 | - $this->assertEquals( 201, $status ); |
|
640 | - $this->assertEquals( 1, count( $header ) ); |
|
641 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
642 | - $this->assertArrayHasKey( 'data', $result ); |
|
643 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
644 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
645 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
646 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
647 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
639 | + $this->assertEquals(201, $status); |
|
640 | + $this->assertEquals(1, count($header)); |
|
641 | + $this->assertEquals(1, $result['meta']['total']); |
|
642 | + $this->assertArrayHasKey('data', $result); |
|
643 | + $this->assertEquals('-1', $result['data']['id']); |
|
644 | + $this->assertEquals('product', $result['data']['type']); |
|
645 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
646 | + $this->assertArrayNotHasKey('included', $result); |
|
647 | + $this->assertArrayNotHasKey('errors', $result); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | $header = array(); |
655 | 655 | $status = 500; |
656 | 656 | |
657 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
657 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
658 | 658 | |
659 | - $this->assertEquals( 400, $status ); |
|
660 | - $this->assertEquals( 1, count( $header ) ); |
|
661 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
662 | - $this->assertArrayHasKey( 'errors', $result ); |
|
663 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
664 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
659 | + $this->assertEquals(400, $status); |
|
660 | + $this->assertEquals(1, count($header)); |
|
661 | + $this->assertEquals(0, $result['meta']['total']); |
|
662 | + $this->assertArrayHasKey('errors', $result); |
|
663 | + $this->assertArrayNotHasKey('included', $result); |
|
664 | + $this->assertArrayNotHasKey('data', $result); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -671,57 +671,57 @@ discard block |
||
671 | 671 | $header = array(); |
672 | 672 | $status = 500; |
673 | 673 | |
674 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
674 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
675 | 675 | |
676 | - $this->assertEquals( 403, $status ); |
|
677 | - $this->assertEquals( 1, count( $header ) ); |
|
678 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
679 | - $this->assertArrayHasKey( 'errors', $result ); |
|
676 | + $this->assertEquals(403, $status); |
|
677 | + $this->assertEquals(1, count($header)); |
|
678 | + $this->assertEquals(0, $result['meta']['total']); |
|
679 | + $this->assertArrayHasKey('errors', $result); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
683 | 683 | public function testPostException() |
684 | 684 | { |
685 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
686 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
685 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
686 | + ->will($this->throwException(new \Exception('test exception'))); |
|
687 | 687 | |
688 | 688 | $header = array(); |
689 | 689 | $status = 500; |
690 | 690 | |
691 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
691 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
692 | 692 | |
693 | - $this->assertEquals( 500, $status ); |
|
694 | - $this->assertArrayHasKey( 'errors', $result ); |
|
693 | + $this->assertEquals(500, $status); |
|
694 | + $this->assertArrayHasKey('errors', $result); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | |
698 | 698 | public function testPostMAdminException() |
699 | 699 | { |
700 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
701 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
700 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
701 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
702 | 702 | |
703 | 703 | $header = array(); |
704 | 704 | $status = 500; |
705 | 705 | |
706 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
706 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
707 | 707 | |
708 | - $this->assertEquals( 404, $status ); |
|
709 | - $this->assertArrayHasKey( 'errors', $result ); |
|
708 | + $this->assertEquals(404, $status); |
|
709 | + $this->assertArrayHasKey('errors', $result); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | |
713 | 713 | public function testPostMShopException() |
714 | 714 | { |
715 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
716 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
715 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
716 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
717 | 717 | |
718 | 718 | $header = array(); |
719 | 719 | $status = 500; |
720 | 720 | |
721 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
721 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
722 | 722 | |
723 | - $this->assertEquals( 404, $status ); |
|
724 | - $this->assertArrayHasKey( 'errors', $result ); |
|
723 | + $this->assertEquals(404, $status); |
|
724 | + $this->assertArrayHasKey('errors', $result); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | |
@@ -731,11 +731,11 @@ discard block |
||
731 | 731 | $header = array(); |
732 | 732 | $status = 500; |
733 | 733 | |
734 | - $result = json_decode( $this->object->put( $body, $header, $status ), true ); |
|
734 | + $result = json_decode($this->object->put($body, $header, $status), true); |
|
735 | 735 | |
736 | - $this->assertEquals( 501, $status ); |
|
737 | - $this->assertEquals( 1, count( $header ) ); |
|
738 | - $this->assertArrayHasKey( 'errors', $result ); |
|
736 | + $this->assertEquals(501, $status); |
|
737 | + $this->assertEquals(1, count($header)); |
|
738 | + $this->assertArrayHasKey('errors', $result); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | |
@@ -744,102 +744,102 @@ discard block |
||
744 | 744 | $header = array(); |
745 | 745 | $status = 500; |
746 | 746 | |
747 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
747 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
748 | 748 | |
749 | - $this->assertEquals( 200, $status ); |
|
750 | - $this->assertEquals( 2, count( $header ) ); |
|
751 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
752 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
753 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
749 | + $this->assertEquals(200, $status); |
|
750 | + $this->assertEquals(2, count($header)); |
|
751 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
752 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
753 | + $this->assertArrayNotHasKey('errors', $result); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | |
757 | 757 | public function testOptionsException() |
758 | 758 | { |
759 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
760 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
759 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
760 | + ->will($this->throwException(new \Exception('test exception'))); |
|
761 | 761 | |
762 | 762 | $header = array(); |
763 | 763 | $status = 500; |
764 | 764 | |
765 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
765 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
766 | 766 | |
767 | - $this->assertEquals( 500, $status ); |
|
768 | - $this->assertArrayHasKey( 'errors', $result ); |
|
767 | + $this->assertEquals(500, $status); |
|
768 | + $this->assertArrayHasKey('errors', $result); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
772 | 772 | public function testOptionsMAdminException() |
773 | 773 | { |
774 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
775 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
774 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
775 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
776 | 776 | |
777 | 777 | $header = array(); |
778 | 778 | $status = 500; |
779 | 779 | |
780 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
780 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
781 | 781 | |
782 | - $this->assertEquals( 404, $status ); |
|
783 | - $this->assertArrayHasKey( 'errors', $result ); |
|
782 | + $this->assertEquals(404, $status); |
|
783 | + $this->assertArrayHasKey('errors', $result); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
787 | 787 | public function testOptionsMShopException() |
788 | 788 | { |
789 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
790 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
789 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
790 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
791 | 791 | |
792 | 792 | $header = array(); |
793 | 793 | $status = 500; |
794 | 794 | |
795 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
795 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
796 | 796 | |
797 | - $this->assertEquals( 404, $status ); |
|
798 | - $this->assertArrayHasKey( 'errors', $result ); |
|
797 | + $this->assertEquals(404, $status); |
|
798 | + $this->assertArrayHasKey('errors', $result); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | |
802 | - protected function getProductMock( array $methods ) |
|
802 | + protected function getProductMock(array $methods) |
|
803 | 803 | { |
804 | 804 | $name = 'ClientJsonAdmStandard'; |
805 | - $this->context->getConfig()->set( 'mshop/product/manager/name', $name ); |
|
805 | + $this->context->getConfig()->set('mshop/product/manager/name', $name); |
|
806 | 806 | |
807 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' ) |
|
808 | - ->setConstructorArgs( array( $this->context ) ) |
|
809 | - ->setMethods( $methods ) |
|
807 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard') |
|
808 | + ->setConstructorArgs(array($this->context)) |
|
809 | + ->setMethods($methods) |
|
810 | 810 | ->getMock(); |
811 | 811 | |
812 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub ); |
|
812 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub); |
|
813 | 813 | |
814 | 814 | return $stub; |
815 | 815 | } |
816 | 816 | |
817 | 817 | |
818 | - protected function getProductListsMock( array $methods ) |
|
818 | + protected function getProductListsMock(array $methods) |
|
819 | 819 | { |
820 | 820 | $name = 'ClientJsonAdmStandard'; |
821 | - $this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name ); |
|
821 | + $this->context->getConfig()->set('mshop/product/manager/lists/name', $name); |
|
822 | 822 | |
823 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
824 | - ->setConstructorArgs( array( $this->context ) ) |
|
825 | - ->setMethods( $methods ) |
|
823 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
824 | + ->setConstructorArgs(array($this->context)) |
|
825 | + ->setMethods($methods) |
|
826 | 826 | ->getMock(); |
827 | 827 | |
828 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub ); |
|
828 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub); |
|
829 | 829 | |
830 | 830 | return $stub; |
831 | 831 | } |
832 | 832 | |
833 | 833 | |
834 | - protected function getProductItem( $code = 'CNC' ) |
|
834 | + protected function getProductItem($code = 'CNC') |
|
835 | 835 | { |
836 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
836 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
837 | 837 | $search = $manager->createSearch(); |
838 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
839 | - $items = $manager->searchItems( $search ); |
|
838 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
839 | + $items = $manager->searchItems($search); |
|
840 | 840 | |
841 | - if( ( $item = reset( $items ) ) === false ) { |
|
842 | - throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) ); |
|
841 | + if (($item = reset($items)) === false) { |
|
842 | + throw new \Exception(sprintf('No product item with code "%1$s" found', $code)); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | return $item; |