@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * @param array $templatePaths List of file system paths where the templates are stored |
37 | 37 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
38 | 38 | */ |
39 | - public function __construct( \Aimeos\Admin\JsonAdm\Iface $client, |
|
40 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
39 | + public function __construct(\Aimeos\Admin\JsonAdm\Iface $client, |
|
40 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
41 | 41 | { |
42 | - parent::__construct( $context, $view, $templatePaths, $path ); |
|
42 | + parent::__construct($context, $view, $templatePaths, $path); |
|
43 | 43 | |
44 | 44 | $this->client = $client; |
45 | 45 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @return mixed Returns the value of the called method |
54 | 54 | * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
55 | 55 | */ |
56 | - public function __call( $name, array $param ) |
|
56 | + public function __call($name, array $param) |
|
57 | 57 | { |
58 | - if( ( $result = call_user_func_array( array( $this->client, $name ), $param ) ) === false ) { |
|
59 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
58 | + if (($result = call_user_func_array(array($this->client, $name), $param)) === false) { |
|
59 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $result; |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
71 | 71 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
72 | 72 | */ |
73 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
73 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
74 | 74 | { |
75 | - return $this->client->delete( $request, $response ); |
|
75 | + return $this->client->delete($request, $response); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
84 | 84 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
85 | 85 | */ |
86 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
86 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
87 | 87 | { |
88 | - return $this->client->get( $request, $response ); |
|
88 | + return $this->client->get($request, $response); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
98 | 98 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
99 | 99 | */ |
100 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
100 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
101 | 101 | { |
102 | - return $this->client->patch( $request, $response ); |
|
102 | + return $this->client->patch($request, $response); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
112 | 112 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
113 | 113 | */ |
114 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
114 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
115 | 115 | { |
116 | - return $this->client->post( $request, $response ); |
|
116 | + return $this->client->post($request, $response); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
126 | 126 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
127 | 127 | */ |
128 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
128 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
129 | 129 | { |
130 | - return $this->client->put( $request, $response ); |
|
130 | + return $this->client->put($request, $response); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
140 | 140 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
141 | 141 | */ |
142 | - public function options( ServerRequestInterface $request, ResponseInterface $response ) |
|
142 | + public function options(ServerRequestInterface $request, ResponseInterface $response) |
|
143 | 143 | { |
144 | - return $this->client->options( $request, $response ); |
|
144 | + return $this->client->options($request, $response); |
|
145 | 145 | } |
146 | 146 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
30 | 30 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
31 | 31 | */ |
32 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ); |
|
32 | + public function delete(ServerRequestInterface $request, ResponseInterface $response); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
40 | 40 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
41 | 41 | */ |
42 | - public function get( ServerRequestInterface $request, ResponseInterface $response ); |
|
42 | + public function get(ServerRequestInterface $request, ResponseInterface $response); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
50 | 50 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
51 | 51 | */ |
52 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ); |
|
52 | + public function patch(ServerRequestInterface $request, ResponseInterface $response); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
60 | 60 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
61 | 61 | */ |
62 | - public function post( ServerRequestInterface $request, ResponseInterface $response ); |
|
62 | + public function post(ServerRequestInterface $request, ResponseInterface $response); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
70 | 70 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
71 | 71 | */ |
72 | - public function put( ServerRequestInterface $request, ResponseInterface $response ); |
|
72 | + public function put(ServerRequestInterface $request, ResponseInterface $response); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -79,5 +79,5 @@ discard block |
||
79 | 79 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
80 | 80 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
81 | 81 | */ |
82 | - public function options( ServerRequestInterface $request, ResponseInterface $response ); |
|
82 | + public function options(ServerRequestInterface $request, ResponseInterface $response); |
|
83 | 83 | } |
@@ -31,38 +31,38 @@ discard block |
||
31 | 31 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
32 | 32 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
33 | 33 | */ |
34 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
34 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
35 | 35 | { |
36 | 36 | $view = $this->getView(); |
37 | 37 | |
38 | 38 | try |
39 | 39 | { |
40 | - $response = $this->deleteItems( $view, $request, $response ); |
|
40 | + $response = $this->deleteItems($view, $request, $response); |
|
41 | 41 | $status = 200; |
42 | 42 | } |
43 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
43 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
44 | 44 | { |
45 | 45 | $status = $e->getCode(); |
46 | - $view->errors = array( array( |
|
47 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
46 | + $view->errors = array(array( |
|
47 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
48 | 48 | 'detail' => $e->getTraceAsString(), |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | } |
51 | - catch( \Aimeos\MShop\Exception $e ) |
|
51 | + catch (\Aimeos\MShop\Exception $e) |
|
52 | 52 | { |
53 | 53 | $status = 404; |
54 | - $view->errors = array( array( |
|
55 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
54 | + $view->errors = array(array( |
|
55 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
56 | 56 | 'detail' => $e->getTraceAsString(), |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | } |
59 | - catch( \Exception $e ) |
|
59 | + catch (\Exception $e) |
|
60 | 60 | { |
61 | 61 | $status = 500; |
62 | - $view->errors = array( array( |
|
62 | + $view->errors = array(array( |
|
63 | 63 | 'title' => $e->getMessage(), |
64 | 64 | 'detail' => $e->getTraceAsString(), |
65 | - ) ); |
|
65 | + )); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** admin/jsonadm/standard/template-delete |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
94 | 94 | $default = 'delete-default.php'; |
95 | 95 | |
96 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
96 | + $body = $view->render($view->config($tplconf, $default)); |
|
97 | 97 | |
98 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
99 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
100 | - ->withStatus( $status ); |
|
98 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
99 | + ->withBody($view->response()->createStreamFromString($body)) |
|
100 | + ->withStatus($status); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -108,33 +108,33 @@ discard block |
||
108 | 108 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
109 | 109 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
110 | 110 | */ |
111 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
111 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
112 | 112 | { |
113 | 113 | $view = $this->getView(); |
114 | 114 | |
115 | 115 | try |
116 | 116 | { |
117 | - $response = $this->getItems( $view, $request, $response ); |
|
117 | + $response = $this->getItems($view, $request, $response); |
|
118 | 118 | $status = 200; |
119 | 119 | } |
120 | - catch( \Aimeos\MShop\Exception $e ) |
|
120 | + catch (\Aimeos\MShop\Exception $e) |
|
121 | 121 | { |
122 | 122 | $status = 404; |
123 | - $view->errors = array( array( |
|
124 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
123 | + $view->errors = array(array( |
|
124 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
125 | 125 | 'detail' => $e->getTraceAsString(), |
126 | - ) ); |
|
126 | + )); |
|
127 | 127 | } |
128 | - catch( \Exception $e ) |
|
128 | + catch (\Exception $e) |
|
129 | 129 | { |
130 | 130 | $status = 500; |
131 | - $view->errors = array( array( |
|
131 | + $view->errors = array(array( |
|
132 | 132 | 'title' => $e->getMessage(), |
133 | 133 | 'detail' => $e->getTraceAsString(), |
134 | - ) ); |
|
134 | + )); |
|
135 | 135 | } |
136 | 136 | |
137 | - if( $view->param( 'aggregate' ) !== null ) |
|
137 | + if ($view->param('aggregate') !== null) |
|
138 | 138 | { |
139 | 139 | /** admin/jsonadm/standard/template-aggregate |
140 | 140 | * Relative path to the JSON API template for GET aggregate requests |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | $default = 'get-default.php'; |
196 | 196 | } |
197 | 197 | |
198 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
198 | + $body = $view->render($view->config($tplconf, $default)); |
|
199 | 199 | |
200 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
201 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
202 | - ->withStatus( $status ); |
|
200 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
201 | + ->withBody($view->response()->createStreamFromString($body)) |
|
202 | + ->withStatus($status); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -210,39 +210,39 @@ discard block |
||
210 | 210 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
211 | 211 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
212 | 212 | */ |
213 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
213 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
214 | 214 | { |
215 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
215 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
216 | 216 | $view = $this->getView(); |
217 | 217 | |
218 | 218 | try |
219 | 219 | { |
220 | - $response = $this->patchItems( $view, $request, $response ); |
|
220 | + $response = $this->patchItems($view, $request, $response); |
|
221 | 221 | $status = 200; |
222 | 222 | } |
223 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
223 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
224 | 224 | { |
225 | 225 | $status = $e->getCode(); |
226 | - $view->errors = array( array( |
|
227 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
226 | + $view->errors = array(array( |
|
227 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
228 | 228 | 'detail' => $e->getTraceAsString(), |
229 | - ) ); |
|
229 | + )); |
|
230 | 230 | } |
231 | - catch( \Aimeos\MShop\Exception $e ) |
|
231 | + catch (\Aimeos\MShop\Exception $e) |
|
232 | 232 | { |
233 | 233 | $status = 404; |
234 | - $view->errors = array( array( |
|
235 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
234 | + $view->errors = array(array( |
|
235 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
236 | 236 | 'detail' => $e->getTraceAsString(), |
237 | - ) ); |
|
237 | + )); |
|
238 | 238 | } |
239 | - catch( \Exception $e ) |
|
239 | + catch (\Exception $e) |
|
240 | 240 | { |
241 | 241 | $status = 500; |
242 | - $view->errors = array( array( |
|
242 | + $view->errors = array(array( |
|
243 | 243 | 'title' => $e->getMessage(), |
244 | 244 | 'detail' => $e->getTraceAsString(), |
245 | - ) ); |
|
245 | + )); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** admin/jsonadm/standard/template-patch |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
274 | 274 | $default = 'patch-default.php'; |
275 | 275 | |
276 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
276 | + $body = $view->render($view->config($tplconf, $default)); |
|
277 | 277 | |
278 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
279 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
280 | - ->withStatus( $status ); |
|
278 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
279 | + ->withBody($view->response()->createStreamFromString($body)) |
|
280 | + ->withStatus($status); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -288,39 +288,39 @@ discard block |
||
288 | 288 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
289 | 289 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
290 | 290 | */ |
291 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
291 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
292 | 292 | { |
293 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
293 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
294 | 294 | $view = $this->getView(); |
295 | 295 | |
296 | 296 | try |
297 | 297 | { |
298 | - $response = $this->postItems( $view, $request, $response ); |
|
298 | + $response = $this->postItems($view, $request, $response); |
|
299 | 299 | $status = 201; |
300 | 300 | } |
301 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
301 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
302 | 302 | { |
303 | 303 | $status = $e->getCode(); |
304 | - $view->errors = array( array( |
|
305 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
304 | + $view->errors = array(array( |
|
305 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
306 | 306 | 'detail' => $e->getTraceAsString(), |
307 | - ) ); |
|
307 | + )); |
|
308 | 308 | } |
309 | - catch( \Aimeos\MShop\Exception $e ) |
|
309 | + catch (\Aimeos\MShop\Exception $e) |
|
310 | 310 | { |
311 | 311 | $status = 404; |
312 | - $view->errors = array( array( |
|
313 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
312 | + $view->errors = array(array( |
|
313 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
314 | 314 | 'detail' => $e->getTraceAsString(), |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | } |
317 | - catch( \Exception $e ) |
|
317 | + catch (\Exception $e) |
|
318 | 318 | { |
319 | 319 | $status = 500; |
320 | - $view->errors = array( array( |
|
320 | + $view->errors = array(array( |
|
321 | 321 | 'title' => $e->getMessage(), |
322 | 322 | 'detail' => $e->getTraceAsString(), |
323 | - ) ); |
|
323 | + )); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** admin/jsonadm/standard/template-post |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | $tplconf = 'admin/jsonadm/standard/template-post'; |
352 | 352 | $default = 'post-default.php'; |
353 | 353 | |
354 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
354 | + $body = $view->render($view->config($tplconf, $default)); |
|
355 | 355 | |
356 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
357 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
358 | - ->withStatus( $status ); |
|
356 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
357 | + ->withBody($view->response()->createStreamFromString($body)) |
|
358 | + ->withStatus($status); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
367 | 367 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
368 | 368 | */ |
369 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
369 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
370 | 370 | { |
371 | 371 | $status = 501; |
372 | 372 | $view = $this->getView(); |
373 | 373 | |
374 | - $view->errors = array( array( |
|
375 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
376 | - ) ); |
|
374 | + $view->errors = array(array( |
|
375 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
376 | + )); |
|
377 | 377 | |
378 | 378 | /** admin/jsonadm/standard/template-put |
379 | 379 | * Relative path to the JSON API template for PUT requests |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $tplconf = 'admin/jsonadm/standard/template-put'; |
404 | 404 | $default = 'put-default.php'; |
405 | 405 | |
406 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
406 | + $body = $view->render($view->config($tplconf, $default)); |
|
407 | 407 | |
408 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
409 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
410 | - ->withStatus( $status ); |
|
408 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
409 | + ->withBody($view->response()->createStreamFromString($body)) |
|
410 | + ->withStatus($status); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
419 | 419 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
420 | 420 | */ |
421 | - public function options( ServerRequestInterface $request, ResponseInterface $response ) |
|
421 | + public function options(ServerRequestInterface $request, ResponseInterface $response) |
|
422 | 422 | { |
423 | 423 | $context = $this->getContext(); |
424 | 424 | $view = $this->getView(); |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | { |
428 | 428 | $resources = $attributes = array(); |
429 | 429 | |
430 | - foreach( $this->getDomains( $view ) as $domain ) |
|
430 | + foreach ($this->getDomains($view) as $domain) |
|
431 | 431 | { |
432 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
433 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
434 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
432 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
433 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
434 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | $view->resources = $resources; |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | |
440 | 440 | $status = 200; |
441 | 441 | } |
442 | - catch( \Aimeos\MShop\Exception $e ) |
|
442 | + catch (\Aimeos\MShop\Exception $e) |
|
443 | 443 | { |
444 | 444 | $status = 404; |
445 | - $view->errors = array( array( |
|
446 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
445 | + $view->errors = array(array( |
|
446 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
447 | 447 | 'detail' => $e->getTraceAsString(), |
448 | - ) ); |
|
448 | + )); |
|
449 | 449 | } |
450 | - catch( \Exception $e ) |
|
450 | + catch (\Exception $e) |
|
451 | 451 | { |
452 | 452 | $status = 500; |
453 | - $view->errors = array( array( |
|
453 | + $view->errors = array(array( |
|
454 | 454 | 'title' => $e->getMessage(), |
455 | 455 | 'detail' => $e->getTraceAsString(), |
456 | - ) ); |
|
456 | + )); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** admin/jsonadm/standard/template-options |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | $tplconf = 'admin/jsonadm/standard/template-options'; |
485 | 485 | $default = 'options-default.php'; |
486 | 486 | |
487 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
487 | + $body = $view->render($view->config($tplconf, $default)); |
|
488 | 488 | |
489 | - return $response->withHeader( 'Allow', 'DELETE,GET,PATCH,POST,OPTIONS' ) |
|
490 | - ->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
491 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
492 | - ->withStatus( $status ); |
|
489 | + return $response->withHeader('Allow', 'DELETE,GET,PATCH,POST,OPTIONS') |
|
490 | + ->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
491 | + ->withBody($view->response()->createStreamFromString($body)) |
|
492 | + ->withStatus($status); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
@@ -502,25 +502,25 @@ discard block |
||
502 | 502 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
503 | 503 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
504 | 504 | */ |
505 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
505 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
506 | 506 | { |
507 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
507 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
508 | 508 | |
509 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
509 | + if (($id = $view->param('id')) == null) |
|
510 | 510 | { |
511 | 511 | $body = (string) $request->getBody(); |
512 | 512 | |
513 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) || !is_array( $payload->data ) ) { |
|
514 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
513 | + if (($payload = json_decode($body)) === null || !isset($payload->data) || !is_array($payload->data)) { |
|
514 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
515 | 515 | } |
516 | 516 | |
517 | - $ids = $this->getIds( $payload ); |
|
518 | - $manager->deleteItems( $ids ); |
|
519 | - $view->total = count( $ids ); |
|
517 | + $ids = $this->getIds($payload); |
|
518 | + $manager->deleteItems($ids); |
|
519 | + $view->total = count($ids); |
|
520 | 520 | } |
521 | 521 | else |
522 | 522 | { |
523 | - $manager->deleteItem( $id ); |
|
523 | + $manager->deleteItem($id); |
|
524 | 524 | $view->total = 1; |
525 | 525 | } |
526 | 526 | |
@@ -536,35 +536,35 @@ discard block |
||
536 | 536 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
537 | 537 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
538 | 538 | */ |
539 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
539 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
540 | 540 | { |
541 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
541 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
542 | 542 | |
543 | - if( ( $key = $view->param( 'aggregate' ) ) !== null ) |
|
543 | + if (($key = $view->param('aggregate')) !== null) |
|
544 | 544 | { |
545 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
546 | - $view->data = $manager->aggregate( $search, $key ); |
|
545 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
546 | + $view->data = $manager->aggregate($search, $key); |
|
547 | 547 | return $response; |
548 | 548 | } |
549 | 549 | |
550 | 550 | $total = 1; |
551 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
551 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
552 | 552 | |
553 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
553 | + if (($id = $view->param('id')) == null) |
|
554 | 554 | { |
555 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
556 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
557 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
558 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
555 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
556 | + $view->data = $manager->searchItems($search, array(), $total); |
|
557 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
558 | + $view->listItems = $this->getListItems($view->data, $include); |
|
559 | 559 | } |
560 | 560 | else |
561 | 561 | { |
562 | - $view->data = $manager->getItem( $id, array() ); |
|
563 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
564 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
562 | + $view->data = $manager->getItem($id, array()); |
|
563 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
564 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
565 | 565 | } |
566 | 566 | |
567 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
567 | + $view->refItems = $this->getRefItems($view->listItems); |
|
568 | 568 | $view->total = $total; |
569 | 569 | |
570 | 570 | return $response; |
@@ -580,35 +580,35 @@ discard block |
||
580 | 580 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
581 | 581 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
582 | 582 | */ |
583 | - protected function patchItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
583 | + protected function patchItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
584 | 584 | { |
585 | 585 | $body = (string) $request->getBody(); |
586 | 586 | |
587 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) { |
|
588 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
587 | + if (($payload = json_decode($body)) === null || !isset($payload->data)) { |
|
588 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
589 | 589 | } |
590 | 590 | |
591 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
591 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
592 | 592 | |
593 | - if( is_array( $payload->data ) ) |
|
593 | + if (is_array($payload->data)) |
|
594 | 594 | { |
595 | - $data = $this->saveData( $manager, $payload ); |
|
595 | + $data = $this->saveData($manager, $payload); |
|
596 | 596 | |
597 | 597 | $view->data = $data; |
598 | - $view->total = count( $data ); |
|
599 | - $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
|
598 | + $view->total = count($data); |
|
599 | + $response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'); |
|
600 | 600 | } |
601 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
601 | + elseif (($id = $view->param('id')) != null) |
|
602 | 602 | { |
603 | 603 | $payload->data->id = $id; |
604 | - $data = $this->saveEntry( $manager, $payload->data ); |
|
604 | + $data = $this->saveEntry($manager, $payload->data); |
|
605 | 605 | |
606 | 606 | $view->data = $data; |
607 | 607 | $view->total = 1; |
608 | 608 | } |
609 | 609 | else |
610 | 610 | { |
611 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
611 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | return $response; |
@@ -623,33 +623,33 @@ discard block |
||
623 | 623 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
624 | 624 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
625 | 625 | */ |
626 | - protected function postItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
626 | + protected function postItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
627 | 627 | { |
628 | 628 | $body = (string) $request->getBody(); |
629 | 629 | |
630 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) { |
|
631 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
630 | + if (($payload = json_decode($body)) === null || !isset($payload->data)) { |
|
631 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
632 | 632 | } |
633 | 633 | |
634 | - if( isset( $payload->data->id ) || $view->param( 'id' ) != null ) { |
|
635 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
634 | + if (isset($payload->data->id) || $view->param('id') != null) { |
|
635 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
639 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
639 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
640 | 640 | |
641 | - if( is_array( $payload->data ) ) |
|
641 | + if (is_array($payload->data)) |
|
642 | 642 | { |
643 | - $data = $this->saveData( $manager, $payload ); |
|
643 | + $data = $this->saveData($manager, $payload); |
|
644 | 644 | |
645 | 645 | $view->data = $data; |
646 | - $view->total = count( $data ); |
|
647 | - $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
|
646 | + $view->total = count($data); |
|
647 | + $response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'); |
|
648 | 648 | } |
649 | 649 | else |
650 | 650 | { |
651 | 651 | $payload->data->id = null; |
652 | - $data = $this->saveEntry( $manager, $payload->data ); |
|
652 | + $data = $this->saveEntry($manager, $payload->data); |
|
653 | 653 | |
654 | 654 | $view->data = $data; |
655 | 655 | $view->total = 1; |