@@ -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 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
37 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
38 | 38 | { |
39 | 39 | $this->view = $view; |
40 | 40 | $this->context = $context; |
@@ -51,48 +51,48 @@ discard block |
||
51 | 51 | * @param integer &$status Variable which contains the HTTP status afterwards |
52 | 52 | * @return string Content for response body |
53 | 53 | */ |
54 | - public function delete( $body, array &$header, &$status ) |
|
54 | + public function delete($body, array &$header, &$status) |
|
55 | 55 | { |
56 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
56 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
57 | 57 | $context = $this->getContext(); |
58 | 58 | $view = $this->getView(); |
59 | 59 | |
60 | 60 | try |
61 | 61 | { |
62 | - $view = $this->deleteItems( $view, $body ); |
|
62 | + $view = $this->deleteItems($view, $body); |
|
63 | 63 | $status = 200; |
64 | 64 | } |
65 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
65 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
66 | 66 | { |
67 | 67 | $status = $e->getCode(); |
68 | - $view->errors = array( array( |
|
69 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
68 | + $view->errors = array(array( |
|
69 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
70 | 70 | 'detail' => $e->getTraceAsString(), |
71 | - ) ); |
|
71 | + )); |
|
72 | 72 | } |
73 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
73 | + catch (\Aimeos\MAdmin\Exception $e) |
|
74 | 74 | { |
75 | 75 | $status = 404; |
76 | - $view->errors = array( array( |
|
77 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
76 | + $view->errors = array(array( |
|
77 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
78 | 78 | 'detail' => $e->getTraceAsString(), |
79 | - ) ); |
|
79 | + )); |
|
80 | 80 | } |
81 | - catch( \Aimeos\MShop\Exception $e ) |
|
81 | + catch (\Aimeos\MShop\Exception $e) |
|
82 | 82 | { |
83 | 83 | $status = 404; |
84 | - $view->errors = array( array( |
|
85 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
84 | + $view->errors = array(array( |
|
85 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
86 | 86 | 'detail' => $e->getTraceAsString(), |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | } |
89 | - catch( \Exception $e ) |
|
89 | + catch (\Exception $e) |
|
90 | 90 | { |
91 | 91 | $status = 500; |
92 | - $view->errors = array( array( |
|
92 | + $view->errors = array(array( |
|
93 | 93 | 'title' => $e->getMessage(), |
94 | 94 | 'detail' => $e->getTraceAsString(), |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** admin/jsonadm/standard/template-delete |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
123 | 123 | $default = 'delete-default.php'; |
124 | 124 | |
125 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
125 | + return $view->render($view->config($tplconf, $default)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -134,39 +134,39 @@ discard block |
||
134 | 134 | * @param integer &$status Variable which contains the HTTP status afterwards |
135 | 135 | * @return string Content for response body |
136 | 136 | */ |
137 | - public function get( $body, array &$header, &$status ) |
|
137 | + public function get($body, array &$header, &$status) |
|
138 | 138 | { |
139 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
139 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
140 | 140 | $view = $this->getView(); |
141 | 141 | |
142 | 142 | try |
143 | 143 | { |
144 | - $view = $this->getItem( $view ); |
|
144 | + $view = $this->getItem($view); |
|
145 | 145 | $status = 200; |
146 | 146 | } |
147 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
147 | + catch (\Aimeos\MAdmin\Exception $e) |
|
148 | 148 | { |
149 | 149 | $status = 404; |
150 | - $view->errors = array( array( |
|
151 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
150 | + $view->errors = array(array( |
|
151 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
152 | 152 | 'detail' => $e->getTraceAsString(), |
153 | - ) ); |
|
153 | + )); |
|
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | 157 | $status = 404; |
158 | - $view->errors = array( array( |
|
159 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
158 | + $view->errors = array(array( |
|
159 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
160 | 160 | 'detail' => $e->getTraceAsString(), |
161 | - ) ); |
|
161 | + )); |
|
162 | 162 | } |
163 | - catch( \Exception $e ) |
|
163 | + catch (\Exception $e) |
|
164 | 164 | { |
165 | 165 | $status = 500; |
166 | - $view->errors = array( array( |
|
166 | + $view->errors = array(array( |
|
167 | 167 | 'title' => $e->getMessage(), |
168 | 168 | 'detail' => $e->getTraceAsString(), |
169 | - ) ); |
|
169 | + )); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** admin/jsonadm/standard/template-get |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $tplconf = 'admin/jsonadm/standard/template-get'; |
197 | 197 | $default = 'get-default.php'; |
198 | 198 | |
199 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
199 | + return $view->render($view->config($tplconf, $default)); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -208,48 +208,48 @@ discard block |
||
208 | 208 | * @param integer &$status Variable which contains the HTTP status afterwards |
209 | 209 | * @return string Content for response body |
210 | 210 | */ |
211 | - public function patch( $body, array &$header, &$status ) |
|
211 | + public function patch($body, array &$header, &$status) |
|
212 | 212 | { |
213 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
213 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
214 | 214 | $context = $this->getContext(); |
215 | 215 | $view = $this->getView(); |
216 | 216 | |
217 | 217 | try |
218 | 218 | { |
219 | - $view = $this->patchItems( $view, $body, $header ); |
|
219 | + $view = $this->patchItems($view, $body, $header); |
|
220 | 220 | $status = 200; |
221 | 221 | } |
222 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
222 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
223 | 223 | { |
224 | 224 | $status = $e->getCode(); |
225 | - $view->errors = array( array( |
|
226 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
225 | + $view->errors = array(array( |
|
226 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
227 | 227 | 'detail' => $e->getTraceAsString(), |
228 | - ) ); |
|
228 | + )); |
|
229 | 229 | } |
230 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
230 | + catch (\Aimeos\MAdmin\Exception $e) |
|
231 | 231 | { |
232 | 232 | $status = 404; |
233 | - $view->errors = array( array( |
|
234 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
233 | + $view->errors = array(array( |
|
234 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
235 | 235 | 'detail' => $e->getTraceAsString(), |
236 | - ) ); |
|
236 | + )); |
|
237 | 237 | } |
238 | - catch( \Aimeos\MShop\Exception $e ) |
|
238 | + catch (\Aimeos\MShop\Exception $e) |
|
239 | 239 | { |
240 | 240 | $status = 404; |
241 | - $view->errors = array( array( |
|
242 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
241 | + $view->errors = array(array( |
|
242 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
243 | 243 | 'detail' => $e->getTraceAsString(), |
244 | - ) ); |
|
244 | + )); |
|
245 | 245 | } |
246 | - catch( \Exception $e ) |
|
246 | + catch (\Exception $e) |
|
247 | 247 | { |
248 | 248 | $status = 500; |
249 | - $view->errors = array( array( |
|
249 | + $view->errors = array(array( |
|
250 | 250 | 'title' => $e->getMessage(), |
251 | 251 | 'detail' => $e->getTraceAsString(), |
252 | - ) ); |
|
252 | + )); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** admin/jsonadm/standard/template-patch |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
280 | 280 | $default = 'patch-default.php'; |
281 | 281 | |
282 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
282 | + return $view->render($view->config($tplconf, $default)); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -291,48 +291,48 @@ discard block |
||
291 | 291 | * @param integer &$status Variable which contains the HTTP status afterwards |
292 | 292 | * @return string Content for response body |
293 | 293 | */ |
294 | - public function post( $body, array &$header, &$status ) |
|
294 | + public function post($body, array &$header, &$status) |
|
295 | 295 | { |
296 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
296 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
297 | 297 | $context = $this->getContext(); |
298 | 298 | $view = $this->getView(); |
299 | 299 | |
300 | 300 | try |
301 | 301 | { |
302 | - $view = $this->postItems( $view, $body, $header ); |
|
302 | + $view = $this->postItems($view, $body, $header); |
|
303 | 303 | $status = 201; |
304 | 304 | } |
305 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
305 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
306 | 306 | { |
307 | 307 | $status = $e->getCode(); |
308 | - $view->errors = array( array( |
|
309 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
308 | + $view->errors = array(array( |
|
309 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
310 | 310 | 'detail' => $e->getTraceAsString(), |
311 | - ) ); |
|
311 | + )); |
|
312 | 312 | } |
313 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
313 | + catch (\Aimeos\MAdmin\Exception $e) |
|
314 | 314 | { |
315 | 315 | $status = 404; |
316 | - $view->errors = array( array( |
|
317 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
316 | + $view->errors = array(array( |
|
317 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
318 | 318 | 'detail' => $e->getTraceAsString(), |
319 | - ) ); |
|
319 | + )); |
|
320 | 320 | } |
321 | - catch( \Aimeos\MShop\Exception $e ) |
|
321 | + catch (\Aimeos\MShop\Exception $e) |
|
322 | 322 | { |
323 | 323 | $status = 404; |
324 | - $view->errors = array( array( |
|
325 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
324 | + $view->errors = array(array( |
|
325 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
326 | 326 | 'detail' => $e->getTraceAsString(), |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | } |
329 | - catch( \Exception $e ) |
|
329 | + catch (\Exception $e) |
|
330 | 330 | { |
331 | 331 | $status = 500; |
332 | - $view->errors = array( array( |
|
332 | + $view->errors = array(array( |
|
333 | 333 | 'title' => $e->getMessage(), |
334 | 334 | 'detail' => $e->getTraceAsString(), |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** admin/jsonadm/standard/template-post |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $tplconf = 'admin/jsonadm/standard/template-post'; |
363 | 363 | $default = 'post-default.php'; |
364 | 364 | |
365 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
365 | + return $view->render($view->config($tplconf, $default)); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | * @param integer &$status Variable which contains the HTTP status afterwards |
375 | 375 | * @return string Content for response body |
376 | 376 | */ |
377 | - public function put( $body, array &$header, &$status ) |
|
377 | + public function put($body, array &$header, &$status) |
|
378 | 378 | { |
379 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
379 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
380 | 380 | $status = 501; |
381 | 381 | |
382 | 382 | $context = $this->getContext(); |
383 | 383 | $view = $this->getView(); |
384 | 384 | |
385 | - $view->errors = array( array( |
|
386 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
387 | - ) ); |
|
385 | + $view->errors = array(array( |
|
386 | + 'title' => $context->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
387 | + )); |
|
388 | 388 | |
389 | 389 | /** admin/jsonadm/standard/template-put |
390 | 390 | * Relative path to the JSON API template for PUT requests |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $tplconf = 'admin/jsonadm/standard/template-put'; |
414 | 414 | $default = 'put-default.php'; |
415 | 415 | |
416 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
416 | + return $view->render($view->config($tplconf, $default)); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param integer &$status Variable which contains the HTTP status afterwards |
426 | 426 | * @return string Content for response body |
427 | 427 | */ |
428 | - public function options( $body, array &$header, &$status ) |
|
428 | + public function options($body, array &$header, &$status) |
|
429 | 429 | { |
430 | 430 | $context = $this->getContext(); |
431 | 431 | $view = $this->getView(); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | { |
435 | 435 | $resources = $attributes = array(); |
436 | 436 | |
437 | - foreach( $this->getDomains( $view ) as $domain ) |
|
437 | + foreach ($this->getDomains($view) as $domain) |
|
438 | 438 | { |
439 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
440 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
441 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
439 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
440 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
441 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $view->resources = $resources; |
@@ -450,29 +450,29 @@ discard block |
||
450 | 450 | ); |
451 | 451 | $status = 200; |
452 | 452 | } |
453 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
453 | + catch (\Aimeos\MAdmin\Exception $e) |
|
454 | 454 | { |
455 | 455 | $status = 404; |
456 | - $view->errors = array( array( |
|
457 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
456 | + $view->errors = array(array( |
|
457 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
458 | 458 | 'detail' => $e->getTraceAsString(), |
459 | - ) ); |
|
459 | + )); |
|
460 | 460 | } |
461 | - catch( \Aimeos\MShop\Exception $e ) |
|
461 | + catch (\Aimeos\MShop\Exception $e) |
|
462 | 462 | { |
463 | 463 | $status = 404; |
464 | - $view->errors = array( array( |
|
465 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
464 | + $view->errors = array(array( |
|
465 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
466 | 466 | 'detail' => $e->getTraceAsString(), |
467 | - ) ); |
|
467 | + )); |
|
468 | 468 | } |
469 | - catch( \Exception $e ) |
|
469 | + catch (\Exception $e) |
|
470 | 470 | { |
471 | 471 | $status = 500; |
472 | - $view->errors = array( array( |
|
472 | + $view->errors = array(array( |
|
473 | 473 | 'title' => $e->getMessage(), |
474 | 474 | 'detail' => $e->getTraceAsString(), |
475 | - ) ); |
|
475 | + )); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** admin/jsonadm/standard/template-options |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | $tplconf = 'admin/jsonadm/standard/template-options'; |
503 | 503 | $default = 'options-default.php'; |
504 | 504 | |
505 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
505 | + return $view->render($view->config($tplconf, $default)); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | |
@@ -514,31 +514,31 @@ discard block |
||
514 | 514 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
515 | 515 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
516 | 516 | */ |
517 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
517 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
518 | 518 | { |
519 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
519 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
520 | 520 | |
521 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
521 | + if (($id = $view->param('id')) == null) |
|
522 | 522 | { |
523 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
524 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
523 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
524 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $ids = array(); |
528 | 528 | |
529 | - foreach( $request->data as $entry ) |
|
529 | + foreach ($request->data as $entry) |
|
530 | 530 | { |
531 | - if( isset( $entry->id ) ) { |
|
531 | + if (isset($entry->id)) { |
|
532 | 532 | $ids[] = $entry->id; |
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | - $manager->deleteItems( $ids ); |
|
537 | - $view->total = count( $ids ); |
|
536 | + $manager->deleteItems($ids); |
|
537 | + $view->total = count($ids); |
|
538 | 538 | } |
539 | 539 | else |
540 | 540 | { |
541 | - $manager->deleteItem( $id ); |
|
541 | + $manager->deleteItem($id); |
|
542 | 542 | $view->total = 1; |
543 | 543 | } |
544 | 544 | |
@@ -552,27 +552,27 @@ discard block |
||
552 | 552 | * @param \Aimeos\MW\View\Iface $view View instance |
553 | 553 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
554 | 554 | */ |
555 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
555 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
556 | 556 | { |
557 | 557 | $total = 1; |
558 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
559 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
558 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
559 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
560 | 560 | |
561 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
561 | + if (($id = $view->param('id')) == null) |
|
562 | 562 | { |
563 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
564 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
565 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
566 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
563 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
564 | + $view->data = $manager->searchItems($search, array(), $total); |
|
565 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
566 | + $view->listItems = $this->getListItems($view->data, $include); |
|
567 | 567 | } |
568 | 568 | else |
569 | 569 | { |
570 | - $view->data = $manager->getItem( $id, array() ); |
|
571 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
572 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
570 | + $view->data = $manager->getItem($id, array()); |
|
571 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
572 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
573 | 573 | } |
574 | 574 | |
575 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
575 | + $view->refItems = $this->getRefItems($view->listItems); |
|
576 | 576 | |
577 | 577 | $view->total = $total; |
578 | 578 | |
@@ -597,11 +597,11 @@ discard block |
||
597 | 597 | * @param array $params List of criteria data with condition, sorting and paging |
598 | 598 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
599 | 599 | */ |
600 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
600 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
601 | 601 | { |
602 | - $this->initCriteriaConditions( $criteria, $params ); |
|
603 | - $this->initCriteriaSortations( $criteria, $params ); |
|
604 | - $this->initCriteriaSlice( $criteria, $params ); |
|
602 | + $this->initCriteriaConditions($criteria, $params); |
|
603 | + $this->initCriteriaSortations($criteria, $params); |
|
604 | + $this->initCriteriaSlice($criteria, $params); |
|
605 | 605 | |
606 | 606 | return $criteria; |
607 | 607 | } |
@@ -613,15 +613,15 @@ discard block |
||
613 | 613 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
614 | 614 | * @param array $params List of criteria data with condition, sorting and paging |
615 | 615 | */ |
616 | - private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
616 | + private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
617 | 617 | { |
618 | - if( isset( $params['filter'] ) && is_array( $params['filter'] ) ) |
|
618 | + if (isset($params['filter']) && is_array($params['filter'])) |
|
619 | 619 | { |
620 | 620 | $existing = $criteria->getConditions(); |
621 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
621 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
622 | 622 | |
623 | - $expr = array( $criteria->getConditions(), $existing ); |
|
624 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
623 | + $expr = array($criteria->getConditions(), $existing); |
|
624 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
@@ -632,12 +632,12 @@ discard block |
||
632 | 632 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
633 | 633 | * @param array $params List of criteria data with condition, sorting and paging |
634 | 634 | */ |
635 | - private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
635 | + private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
636 | 636 | { |
637 | - $start = ( isset( $params['page']['offset'] ) ? $params['page']['offset'] : 0 ); |
|
638 | - $size = ( isset( $params['page']['limit'] ) ? $params['page']['limit'] : 25 ); |
|
637 | + $start = (isset($params['page']['offset']) ? $params['page']['offset'] : 0); |
|
638 | + $size = (isset($params['page']['limit']) ? $params['page']['limit'] : 25); |
|
639 | 639 | |
640 | - $criteria->setSlice( $start, $size ); |
|
640 | + $criteria->setSlice($start, $size); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -647,24 +647,24 @@ discard block |
||
647 | 647 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
648 | 648 | * @param array $params List of criteria data with condition, sorting and paging |
649 | 649 | */ |
650 | - private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
650 | + private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
651 | 651 | { |
652 | - if( !isset( $params['sort'] ) ) { |
|
652 | + if (!isset($params['sort'])) { |
|
653 | 653 | return; |
654 | 654 | } |
655 | 655 | |
656 | 656 | $sortation = array(); |
657 | 657 | |
658 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
658 | + foreach (explode(',', $params['sort']) as $sort) |
|
659 | 659 | { |
660 | - if( $sort[0] === '-' ) { |
|
661 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
660 | + if ($sort[0] === '-') { |
|
661 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
662 | 662 | } else { |
663 | - $sortation[] = $criteria->sort( '+', $sort ); break; |
|
663 | + $sortation[] = $criteria->sort('+', $sort); break; |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
667 | - $criteria->setSortations( $sortation ); |
|
667 | + $criteria->setSortations($sortation); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
675 | 675 | * @return array List of domain names |
676 | 676 | */ |
677 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
677 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
678 | 678 | { |
679 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
679 | + if (($domains = $view->param('resource')) == '') |
|
680 | 680 | { |
681 | 681 | /** admin/jsonadm/domains |
682 | 682 | * A list of domain names whose clients are available for the JSON API |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
699 | 699 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
700 | 700 | ); |
701 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
701 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | return (array) $domains; |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param array $include List of resource types that should be fetched |
713 | 713 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
714 | 714 | */ |
715 | - protected function getChildItems( array $items, array $include ) |
|
715 | + protected function getChildItems(array $items, array $include) |
|
716 | 716 | { |
717 | 717 | return array(); |
718 | 718 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @param array $include List of resource types that should be fetched |
726 | 726 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
727 | 727 | */ |
728 | - protected function getListItems( array $items, array $include ) |
|
728 | + protected function getListItems(array $items, array $include) |
|
729 | 729 | { |
730 | 730 | return array(); |
731 | 731 | } |
@@ -737,22 +737,22 @@ discard block |
||
737 | 737 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
738 | 738 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
739 | 739 | */ |
740 | - protected function getRefItems( array $listItems ) |
|
740 | + protected function getRefItems(array $listItems) |
|
741 | 741 | { |
742 | 742 | $list = $map = array(); |
743 | 743 | |
744 | - foreach( $listItems as $listItem ) { |
|
744 | + foreach ($listItems as $listItem) { |
|
745 | 745 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
746 | 746 | } |
747 | 747 | |
748 | - foreach( $map as $domain => $ids ) |
|
748 | + foreach ($map as $domain => $ids) |
|
749 | 749 | { |
750 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
750 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
751 | 751 | |
752 | 752 | $search = $manager->createSearch(); |
753 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
753 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
754 | 754 | |
755 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
755 | + $list = array_merge($list, $manager->searchItems($search)); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | return $list; |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
802 | 802 | * @return \Aimeos\MW\View\Iface Updated view instance |
803 | 803 | */ |
804 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
804 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
805 | 805 | { |
806 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
807 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
806 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
807 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
808 | 808 | } |
809 | 809 | |
810 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
810 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
811 | 811 | |
812 | - if( is_array( $request->data ) ) |
|
812 | + if (is_array($request->data)) |
|
813 | 813 | { |
814 | - $data = $this->saveData( $manager, $request ); |
|
814 | + $data = $this->saveData($manager, $request); |
|
815 | 815 | |
816 | 816 | $view->data = $data; |
817 | - $view->total = count( $data ); |
|
817 | + $view->total = count($data); |
|
818 | 818 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
819 | 819 | } |
820 | 820 | else |
821 | 821 | { |
822 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
823 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
822 | + if (($id = $view->param('id')) == null) { |
|
823 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | $request->data->id = $id; |
827 | - $data = $this->saveEntry( $manager, $request->data ); |
|
827 | + $data = $this->saveEntry($manager, $request->data); |
|
828 | 828 | |
829 | 829 | $view->data = $data; |
830 | 830 | $view->total = 1; |
@@ -842,31 +842,31 @@ discard block |
||
842 | 842 | * @param array &$header Associative list of HTTP headers as value/result parameter |
843 | 843 | * @return \Aimeos\MW\View\Iface Updated view instance |
844 | 844 | */ |
845 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
845 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
846 | 846 | { |
847 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
848 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
847 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
848 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
849 | 849 | } |
850 | 850 | |
851 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
852 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
851 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
852 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
856 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
856 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
857 | 857 | |
858 | - if( is_array( $request->data ) ) |
|
858 | + if (is_array($request->data)) |
|
859 | 859 | { |
860 | - $data = $this->saveData( $manager, $request ); |
|
860 | + $data = $this->saveData($manager, $request); |
|
861 | 861 | |
862 | 862 | $view->data = $data; |
863 | - $view->total = count( $data ); |
|
863 | + $view->total = count($data); |
|
864 | 864 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
865 | 865 | } |
866 | 866 | else |
867 | 867 | { |
868 | 868 | $request->data->id = null; |
869 | - $data = $this->saveEntry( $manager, $request->data ); |
|
869 | + $data = $this->saveEntry($manager, $request->data); |
|
870 | 870 | |
871 | 871 | $view->data = $data; |
872 | 872 | $view->total = 1; |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | * @param \stdClass $request Object with request body data |
884 | 884 | * @return array List of items |
885 | 885 | */ |
886 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
886 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
887 | 887 | { |
888 | 888 | $data = array(); |
889 | 889 | |
890 | - if( isset( $request->data ) ) |
|
890 | + if (isset($request->data)) |
|
891 | 891 | { |
892 | - foreach( (array) $request->data as $entry ) { |
|
893 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
892 | + foreach ((array) $request->data as $entry) { |
|
893 | + $data[] = $this->saveEntry($manager, $entry); |
|
894 | 894 | } |
895 | 895 | } |
896 | 896 | |
@@ -905,19 +905,19 @@ discard block |
||
905 | 905 | * @param \stdClass $entry Object including "id" and "attributes" elements |
906 | 906 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
907 | 907 | */ |
908 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
908 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
909 | 909 | { |
910 | - $attr = ( isset( $entry->attributes ) ? (array) $entry->attributes : array() ); |
|
910 | + $attr = (isset($entry->attributes) ? (array) $entry->attributes : array()); |
|
911 | 911 | |
912 | - if( isset( $entry->id ) && $entry->id !== null ) { |
|
913 | - $item = $manager->getItem( $entry->id ); |
|
912 | + if (isset($entry->id) && $entry->id !== null) { |
|
913 | + $item = $manager->getItem($entry->id); |
|
914 | 914 | } else { |
915 | 915 | $item = $manager->createItem(); |
916 | 916 | } |
917 | 917 | |
918 | - $item->fromArray( $attr ); |
|
919 | - $manager->saveItem( $item ); |
|
918 | + $item->fromArray($attr); |
|
919 | + $manager->saveItem($item); |
|
920 | 920 | |
921 | - return $manager->getItem( $item->getId() ); |
|
921 | + return $manager->getItem($item->getId()); |
|
922 | 922 | } |
923 | 923 | } |
@@ -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 ); |