Completed
Push — master ( 00af66...7df475 )
by Aimeos
02:30
created
admin/jsonadm/templates/options-default.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$target = $this->config( 'admin/jsonadm/url/target' );
4
-$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' );
5
-$action = $this->config( 'admin/jsonadm/url/action', 'get' );
6
-$config = $this->config( 'admin/jsonadm/url/config', array() );
3
+$target = $this->config('admin/jsonadm/url/target');
4
+$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm');
5
+$action = $this->config('admin/jsonadm/url/action', 'get');
6
+$config = $this->config('admin/jsonadm/url/config', array());
7 7
 
8 8
 $resources = $attributes = array();
9
-$site = $this->param( 'site', 'default' );
9
+$site = $this->param('site', 'default');
10 10
 
11
-foreach( $this->get( 'resources', array() ) as $resource ) {
12
-	$resources[$resource] = $this->url( $target, $cntl, $action, array( 'site' => $site, 'resource' => $resource, 'id' => '' ), array(), $config );
11
+foreach ($this->get('resources', array()) as $resource) {
12
+	$resources[$resource] = $this->url($target, $cntl, $action, array('site' => $site, 'resource' => $resource, 'id' => ''), array(), $config);
13 13
 }
14 14
 
15
-foreach( $this->get( 'attributes', array() ) as $attr ) {
15
+foreach ($this->get('attributes', array()) as $attr) {
16 16
 	$attributes[$attr->getCode()] = $attr->toArray();
17 17
 }
18 18
 
19 19
 ?>
20 20
 {
21 21
 	"meta": {
22
-		"resources": <?php echo json_encode( $resources ); ?>,
23
-		"attributes": <?php echo json_encode( $attributes ); ?>
22
+		"resources": <?php echo json_encode($resources); ?>,
23
+		"attributes": <?php echo json_encode($attributes); ?>
24 24
 	}
25
-<?php if( isset( $this->errors ) ) : ?>
26
-	,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
25
+<?php if (isset($this->errors)) : ?>
26
+	,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
27 27
 <?php endif; ?>
28 28
 
29 29
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/put-default.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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 ) ); ?>
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 4
 <?php endif; ?>
5 5
 
6 6
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/get-default.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * @see admin/jsonadm/url/action
15 15
  * @see admin/jsonadm/url/config
16 16
  */
17
-$target = $this->config( 'admin/jsonadm/url/target' );
17
+$target = $this->config('admin/jsonadm/url/target');
18 18
 
19 19
 /** admin/jsonadm/url/controller
20 20
  * Name of the client whose action should be called
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @see admin/jsonadm/url/action
31 31
  * @see admin/jsonadm/url/config
32 32
  */
33
-$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' );
33
+$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm');
34 34
 
35 35
 /** admin/jsonadm/url/action
36 36
  * Name of the action that should create the output
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @see admin/jsonadm/url/controller
47 47
  * @see admin/jsonadm/url/config
48 48
  */
49
-$action = $this->config( 'admin/jsonadm/url/action', 'get' );
49
+$action = $this->config('admin/jsonadm/url/action', 'get');
50 50
 
51 51
 /** admin/jsonadm/url/config
52 52
  * Associative list of configuration options used for generating the URL
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * @see admin/jsonadm/url/controller
69 69
  * @see admin/jsonadm/url/action
70 70
  */
71
-$config = $this->config( 'admin/jsonadm/url/config', array() );
71
+$config = $this->config('admin/jsonadm/url/config', array());
72 72
 
73 73
 
74 74
 /** admin/jsonadm/partials/template-errors
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
  */
121 121
 
122 122
 
123
-$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' );
124
-$params = array_intersect_key( $this->param(), array_flip( $ref ) );
123
+$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields');
124
+$params = array_intersect_key($this->param(), array_flip($ref));
125 125
 
126
-if( !isset( $params['id'] ) ) {
126
+if (!isset($params['id'])) {
127 127
 	$params['id'] = '';
128 128
 }
129 129
 
130 130
 
131
-$total = $this->get( 'total', 0 );
132
-$offset = max( $this->param( 'page/offset', 0 ), 0 );
133
-$limit = max( $this->param( 'page/limit', 25 ), 1 );
131
+$total = $this->get('total', 0);
132
+$offset = max($this->param('page/offset', 0), 0);
133
+$limit = max($this->param('page/limit', 25), 1);
134 134
 
135
-$first = ( $offset > 0 ? 0 : null );
136
-$prev = ( $offset - $limit >= 0 ? $offset - $limit : null );
137
-$next = ( $offset + $limit < $total ? $offset + $limit : null );
138
-$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null );
135
+$first = ($offset > 0 ? 0 : null);
136
+$prev = ($offset - $limit >= 0 ? $offset - $limit : null);
137
+$next = ($offset + $limit < $total ? $offset + $limit : null);
138
+$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null);
139 139
 
140 140
 ?>
141 141
 {
@@ -144,27 +144,27 @@  discard block
 block discarded – undo
144 144
 
145 145
 	},
146 146
 	"links": {
147
-<?php if( is_array( $this->get( 'data' ) ) ) : ?>
148
-<?php	if( $first !== null ) : ?>
149
-		"first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>",
147
+<?php if (is_array($this->get('data'))) : ?>
148
+<?php	if ($first !== null) : ?>
149
+		"first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>",
150 150
 <?php	endif; ?>
151
-<?php	if( $prev !== null ) : ?>
152
-		"prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>",
151
+<?php	if ($prev !== null) : ?>
152
+		"prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>",
153 153
 <?php	endif; ?>
154
-<?php	if( $next !== null ) : ?>
155
-		"next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>",
154
+<?php	if ($next !== null) : ?>
155
+		"next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>",
156 156
 <?php	endif; ?>
157
-<?php	if( $last !== null ) : ?>
158
-		"last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>",
157
+<?php	if ($last !== null) : ?>
158
+		"last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>",
159 159
 <?php	endif; ?>
160 160
 <?php endif; ?>
161
-		"self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>"
161
+		"self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>"
162 162
 	},
163
-<?php if( isset( $this->errors ) ) : ?>
164
-	"errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
165
-<?php elseif( isset( $this->data ) ) : ?>
166
-	"data": <?php echo $this->partial( $this->config( $this->get( 'partial-data', 'admin/jsonadm/partials/template-data' ), 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ), 'childItems' => $this->get( 'childItems', array() ), 'listItems' => $this->get( 'listItems', array() ) ) ); ?>,
167
-	"included": <?php echo $this->partial( $this->config( $this->get( 'partial-included', 'admin/jsonadm/partials/template-included' ), 'partials/included-standard.php' ), array( 'childItems' => $this->get( 'childItems', array() ), 'refItems' => $this->get( 'refItems', array() ) ) ); ?>
163
+<?php if (isset($this->errors)) : ?>
164
+	"errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
165
+<?php elseif (isset($this->data)) : ?>
166
+	"data": <?php echo $this->partial($this->config($this->get('partial-data', 'admin/jsonadm/partials/template-data'), 'partials/data-standard.php'), array('data' => $this->get('data'), 'childItems' => $this->get('childItems', array()), 'listItems' => $this->get('listItems', array()))); ?>,
167
+	"included": <?php echo $this->partial($this->config($this->get('partial-included', 'admin/jsonadm/partials/template-included'), 'partials/included-standard.php'), array('childItems' => $this->get('childItems', array()), 'refItems' => $this->get('refItems', array()))); ?>
168 168
 <?php endif; ?>
169 169
 
170 170
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/delete-default.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Base.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -49,6 +49,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 )
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -44 removed lines patch added patch discarded remove patch
@@ -61,32 +61,28 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 );
Please login to merge, or discard this patch.
admin/jsonadm/templates/post-default.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/StandardTest.php 1 patch
Spacing   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,120 +488,120 @@  discard block
 block discarded – undo
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( 'getItem', 'saveItem' ) );
547
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
548 548
 
549 549
 		$item = $productManagerStub->createItem();
550
-		$item->setLabel( 'test' );
551
-		$item->setId( '-1' );
550
+		$item->setLabel('test');
551
+		$item->setId('-1');
552 552
 
553
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' );
554
-		$productManagerStub->expects( $this->once() )->method( 'getItem' )
555
-			->will( $this->returnValue( $item ) );
553
+		$productManagerStub->expects($this->once())->method('saveItem');
554
+		$productManagerStub->expects($this->once())->method('getItem')
555
+			->will($this->returnValue($item));
556 556
 
557 557
 
558 558
 		$body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}';
559 559
 		$header = array();
560 560
 		$status = 500;
561 561
 
562
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
562
+		$result = json_decode($this->object->post($body, $header, $status), true);
563 563
 
564
-		$this->assertEquals( 201, $status );
565
-		$this->assertEquals( 1, count( $header ) );
566
-		$this->assertEquals( 1, $result['meta']['total'] );
567
-		$this->assertArrayHasKey( 'data', $result );
568
-		$this->assertEquals( '-1', $result['data']['id'] );
569
-		$this->assertEquals( 'product', $result['data']['type'] );
570
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
571
-		$this->assertArrayNotHasKey( 'included', $result );
572
-		$this->assertArrayNotHasKey( 'errors', $result );
564
+		$this->assertEquals(201, $status);
565
+		$this->assertEquals(1, count($header));
566
+		$this->assertEquals(1, $result['meta']['total']);
567
+		$this->assertArrayHasKey('data', $result);
568
+		$this->assertEquals('-1', $result['data']['id']);
569
+		$this->assertEquals('product', $result['data']['type']);
570
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
571
+		$this->assertArrayNotHasKey('included', $result);
572
+		$this->assertArrayNotHasKey('errors', $result);
573 573
 	}
574 574
 
575 575
 
576 576
 	public function testPostBulk()
577 577
 	{
578
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
578
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
579 579
 
580 580
 		$item = $productManagerStub->createItem();
581
-		$item->setLabel( 'test' );
582
-		$item->setId( '-1' );
581
+		$item->setLabel('test');
582
+		$item->setId('-1');
583 583
 
584
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' );
585
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' )
586
-			->will( $this->returnValue( $item ) );
584
+		$productManagerStub->expects($this->exactly(2))->method('saveItem');
585
+		$productManagerStub->expects($this->exactly(2))->method('getItem')
586
+			->will($this->returnValue($item));
587 587
 
588 588
 
589 589
 		$body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}';
590 590
 		$header = array();
591 591
 		$status = 500;
592 592
 
593
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
593
+		$result = json_decode($this->object->post($body, $header, $status), true);
594 594
 
595
-		$this->assertEquals( 201, $status );
596
-		$this->assertEquals( 1, count( $header ) );
597
-		$this->assertEquals( 2, $result['meta']['total'] );
598
-		$this->assertArrayHasKey( 'data', $result );
599
-		$this->assertEquals( 2, count( $result['data'] ) );
600
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
601
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
602
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
603
-		$this->assertArrayNotHasKey( 'included', $result );
604
-		$this->assertArrayNotHasKey( 'errors', $result );
595
+		$this->assertEquals(201, $status);
596
+		$this->assertEquals(1, count($header));
597
+		$this->assertEquals(2, $result['meta']['total']);
598
+		$this->assertArrayHasKey('data', $result);
599
+		$this->assertEquals(2, count($result['data']));
600
+		$this->assertEquals('-1', $result['data'][0]['id']);
601
+		$this->assertEquals('product', $result['data'][0]['type']);
602
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
603
+		$this->assertArrayNotHasKey('included', $result);
604
+		$this->assertArrayNotHasKey('errors', $result);
605 605
 	}
606 606
 
607 607
 
@@ -611,14 +611,14 @@  discard block
 block discarded – undo
611 611
 		$header = array();
612 612
 		$status = 500;
613 613
 
614
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
614
+		$result = json_decode($this->object->post($body, $header, $status), true);
615 615
 
616
-		$this->assertEquals( 400, $status );
617
-		$this->assertEquals( 1, count( $header ) );
618
-		$this->assertEquals( 0, $result['meta']['total'] );
619
-		$this->assertArrayHasKey( 'errors', $result );
620
-		$this->assertArrayNotHasKey( 'included', $result );
621
-		$this->assertArrayNotHasKey( 'data', $result );
616
+		$this->assertEquals(400, $status);
617
+		$this->assertEquals(1, count($header));
618
+		$this->assertEquals(0, $result['meta']['total']);
619
+		$this->assertArrayHasKey('errors', $result);
620
+		$this->assertArrayNotHasKey('included', $result);
621
+		$this->assertArrayNotHasKey('data', $result);
622 622
 	}
623 623
 
624 624
 
@@ -628,57 +628,57 @@  discard block
 block discarded – undo
628 628
 		$header = array();
629 629
 		$status = 500;
630 630
 
631
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
631
+		$result = json_decode($this->object->post($body, $header, $status), true);
632 632
 
633
-		$this->assertEquals( 403, $status );
634
-		$this->assertEquals( 1, count( $header ) );
635
-		$this->assertEquals( 0, $result['meta']['total'] );
636
-		$this->assertArrayHasKey( 'errors', $result );
633
+		$this->assertEquals(403, $status);
634
+		$this->assertEquals(1, count($header));
635
+		$this->assertEquals(0, $result['meta']['total']);
636
+		$this->assertArrayHasKey('errors', $result);
637 637
 	}
638 638
 
639 639
 
640 640
 	public function testPostException()
641 641
 	{
642
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
643
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
642
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
643
+			->will($this->throwException(new \Exception('test exception')));
644 644
 
645 645
 		$header = array();
646 646
 		$status = 500;
647 647
 
648
-		$result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true );
648
+		$result = json_decode($this->object->post('{"data":{}}', $header, $status), true);
649 649
 
650
-		$this->assertEquals( 500, $status );
651
-		$this->assertArrayHasKey( 'errors', $result );
650
+		$this->assertEquals(500, $status);
651
+		$this->assertArrayHasKey('errors', $result);
652 652
 	}
653 653
 
654 654
 
655 655
 	public function testPostMAdminException()
656 656
 	{
657
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
658
-			->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) );
657
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
658
+			->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception')));
659 659
 
660 660
 		$header = array();
661 661
 		$status = 500;
662 662
 
663
-		$result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true );
663
+		$result = json_decode($this->object->post('{"data":{}}', $header, $status), true);
664 664
 
665
-		$this->assertEquals( 404, $status );
666
-		$this->assertArrayHasKey( 'errors', $result );
665
+		$this->assertEquals(404, $status);
666
+		$this->assertArrayHasKey('errors', $result);
667 667
 	}
668 668
 
669 669
 
670 670
 	public function testPostMShopException()
671 671
 	{
672
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
673
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
672
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
673
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
674 674
 
675 675
 		$header = array();
676 676
 		$status = 500;
677 677
 
678
-		$result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true );
678
+		$result = json_decode($this->object->post('{"data":{}}', $header, $status), true);
679 679
 
680
-		$this->assertEquals( 404, $status );
681
-		$this->assertArrayHasKey( 'errors', $result );
680
+		$this->assertEquals(404, $status);
681
+		$this->assertArrayHasKey('errors', $result);
682 682
 	}
683 683
 
684 684
 
@@ -688,11 +688,11 @@  discard block
 block discarded – undo
688 688
 		$header = array();
689 689
 		$status = 500;
690 690
 
691
-		$result = json_decode( $this->object->put( $body, $header, $status ), true );
691
+		$result = json_decode($this->object->put($body, $header, $status), true);
692 692
 
693
-		$this->assertEquals( 501, $status );
694
-		$this->assertEquals( 1, count( $header ) );
695
-		$this->assertArrayHasKey( 'errors', $result );
693
+		$this->assertEquals(501, $status);
694
+		$this->assertEquals(1, count($header));
695
+		$this->assertArrayHasKey('errors', $result);
696 696
 	}
697 697
 
698 698
 
@@ -701,86 +701,86 @@  discard block
 block discarded – undo
701 701
 		$header = array();
702 702
 		$status = 500;
703 703
 
704
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
704
+		$result = json_decode($this->object->options('', $header, $status), true);
705 705
 
706
-		$this->assertEquals( 200, $status );
707
-		$this->assertEquals( 2, count( $header ) );
708
-		$this->assertEquals( 59, count( $result['meta']['resources'] ) );
709
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
710
-		$this->assertArrayNotHasKey( 'errors', $result );
706
+		$this->assertEquals(200, $status);
707
+		$this->assertEquals(2, count($header));
708
+		$this->assertEquals(59, count($result['meta']['resources']));
709
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
710
+		$this->assertArrayNotHasKey('errors', $result);
711 711
 	}
712 712
 
713 713
 
714 714
 	public function testOptionsException()
715 715
 	{
716
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
717
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
716
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
717
+			->will($this->throwException(new \Exception('test exception')));
718 718
 
719 719
 		$header = array();
720 720
 		$status = 500;
721 721
 
722
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
722
+		$result = json_decode($this->object->options('', $header, $status), true);
723 723
 
724
-		$this->assertEquals( 500, $status );
725
-		$this->assertArrayHasKey( 'errors', $result );
724
+		$this->assertEquals(500, $status);
725
+		$this->assertArrayHasKey('errors', $result);
726 726
 	}
727 727
 
728 728
 
729 729
 	public function testOptionsMAdminException()
730 730
 	{
731
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
732
-			->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) );
731
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
732
+			->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception')));
733 733
 
734 734
 		$header = array();
735 735
 		$status = 500;
736 736
 
737
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
737
+		$result = json_decode($this->object->options('', $header, $status), true);
738 738
 
739
-		$this->assertEquals( 404, $status );
740
-		$this->assertArrayHasKey( 'errors', $result );
739
+		$this->assertEquals(404, $status);
740
+		$this->assertArrayHasKey('errors', $result);
741 741
 	}
742 742
 
743 743
 
744 744
 	public function testOptionsMShopException()
745 745
 	{
746
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
747
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
746
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
747
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
748 748
 
749 749
 		$header = array();
750 750
 		$status = 500;
751 751
 
752
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
752
+		$result = json_decode($this->object->options('', $header, $status), true);
753 753
 
754
-		$this->assertEquals( 404, $status );
755
-		$this->assertArrayHasKey( 'errors', $result );
754
+		$this->assertEquals(404, $status);
755
+		$this->assertArrayHasKey('errors', $result);
756 756
 	}
757 757
 
758 758
 
759
-	protected function getProductMock( array $methods )
759
+	protected function getProductMock(array $methods)
760 760
 	{
761 761
 		$name = 'ClientJsonAdmStandard';
762
-		$this->context->getConfig()->set( 'mshop/product/manager/name', $name );
762
+		$this->context->getConfig()->set('mshop/product/manager/name', $name);
763 763
 
764
-		$productManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' )
765
-			->setConstructorArgs( array( $this->context ) )
766
-			->setMethods( $methods )
764
+		$productManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')
765
+			->setConstructorArgs(array($this->context))
766
+			->setMethods($methods)
767 767
 			->getMock();
768 768
 
769
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $productManagerStub );
769
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $productManagerStub);
770 770
 
771 771
 		return $productManagerStub;
772 772
 	}
773 773
 
774 774
 
775
-	protected function getProductItem( $code = 'CNC' )
775
+	protected function getProductItem($code = 'CNC')
776 776
 	{
777
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
777
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
778 778
 		$search = $manager->createSearch();
779
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
780
-		$items = $manager->searchItems( $search );
779
+		$search->setConditions($search->compare('==', 'product.code', $code));
780
+		$items = $manager->searchItems($search);
781 781
 
782
-		if( ( $item = reset( $items ) ) === false ) {
783
-			throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) );
782
+		if (($item = reset($items)) === false) {
783
+			throw new \Exception(sprintf('No product item with code "%1$s" found', $code));
784 784
 		}
785 785
 
786 786
 		return $item;
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/FactoryTest.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Factory.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,8 +136,7 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.