Completed
Push — master ( c33cfb...4b3479 )
by Aimeos
05:50
created
admin/jsonadm/src/Admin/JsonAdm/Base.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param array $templatePaths List of file system paths where the templates are stored
34 34
 	 * @param string $path Name of the client separated by slashes, e.g "product/stock"
35 35
 	 */
36
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path )
36
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path)
37 37
 	{
38 38
 		$this->view = $view;
39 39
 		$this->context = $context;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param array $include List of resource types that should be fetched
50 50
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
51 51
 	 */
52
-	protected function getChildItems( array $items, array $include )
52
+	protected function getChildItems(array $items, array $include)
53 53
 	{
54 54
 		return array();
55 55
 	}
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter
73 73
 	 * @return array List of domain names
74 74
 	 */
75
-	protected function getDomains( \Aimeos\MW\View\Iface $view )
75
+	protected function getDomains(\Aimeos\MW\View\Iface $view)
76 76
 	{
77
-		if( ( $domains = $view->param( 'resource' ) ) == '' )
77
+		if (($domains = $view->param('resource')) == '')
78 78
 		{
79 79
 			/** admin/jsonadm/domains
80 80
 			 * A list of domain names whose clients are available for the JSON API
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media',
97 97
 				'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text'
98 98
 			);
99
-			$domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default );
99
+			$domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default);
100 100
 		}
101 101
 
102 102
 		return (array) $domains;
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 	 * @param \stdClass $request Decoded request body
110 110
 	 * @return array List of item IDs
111 111
 	 */
112
-	protected function getIds( $request )
112
+	protected function getIds($request)
113 113
 	{
114 114
 		$ids = array();
115 115
 
116
-		if( isset( $request->data ) )
116
+		if (isset($request->data))
117 117
 		{
118
-			foreach( (array) $request->data as $entry )
118
+			foreach ((array) $request->data as $entry)
119 119
 			{
120
-				if( isset( $entry->id ) ) {
120
+				if (isset($entry->id)) {
121 121
 					$ids[] = $entry->id;
122 122
 				}
123 123
 			}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param array $include List of resource types that should be fetched
135 135
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
136 136
 	 */
137
-	protected function getListItems( array $items, array $include )
137
+	protected function getListItems(array $items, array $include)
138 138
 	{
139 139
 		return array();
140 140
 	}
@@ -157,23 +157,23 @@  discard block
 block discarded – undo
157 157
 	 * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
158 158
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
159 159
 	 */
160
-	protected function getRefItems( array $listItems )
160
+	protected function getRefItems(array $listItems)
161 161
 	{
162 162
 		$list = $map = array();
163 163
 		$context = $this->getContext();
164 164
 
165
-		foreach( $listItems as $listItem ) {
165
+		foreach ($listItems as $listItem) {
166 166
 			$map[$listItem->getDomain()][] = $listItem->getRefId();
167 167
 		}
168 168
 
169
-		foreach( $map as $domain => $ids )
169
+		foreach ($map as $domain => $ids)
170 170
 		{
171
-			$manager = \Aimeos\MShop\Factory::createManager( $context, $domain );
171
+			$manager = \Aimeos\MShop\Factory::createManager($context, $domain);
172 172
 
173 173
 			$search = $manager->createSearch();
174
-			$search->setConditions( $search->compare( '==', $domain . '.id', $ids ) );
174
+			$search->setConditions($search->compare('==', $domain . '.id', $ids));
175 175
 
176
-			$list = array_merge( $list, $manager->searchItems( $search ) );
176
+			$list = array_merge($list, $manager->searchItems($search));
177 177
 		}
178 178
 
179 179
 		return $list;
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	 * @param array $params List of criteria data with condition, sorting and paging
210 210
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
211 211
 	 */
212
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params )
212
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params)
213 213
 	{
214
-		$this->initCriteriaConditions( $criteria, $params );
215
-		$this->initCriteriaSortations( $criteria, $params );
216
-		$this->initCriteriaSlice( $criteria, $params );
214
+		$this->initCriteriaConditions($criteria, $params);
215
+		$this->initCriteriaSortations($criteria, $params);
216
+		$this->initCriteriaSlice($criteria, $params);
217 217
 
218 218
 		return $criteria;
219 219
 	}
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
226 226
 	 * @param array $params List of criteria data with condition, sorting and paging
227 227
 	 */
228
-	protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params )
228
+	protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params)
229 229
 	{
230
-		if( !isset( $params['filter'] ) ) {
230
+		if (!isset($params['filter'])) {
231 231
 			return;
232 232
 		}
233 233
 
234 234
 		$existing = $criteria->getConditions();
235
-		$criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) );
235
+		$criteria->setConditions($criteria->toConditions((array) $params['filter']));
236 236
 
237
-		$expr = array( $criteria->getConditions(), $existing );
238
-		$criteria->setConditions( $criteria->combine( '&&', $expr ) );
237
+		$expr = array($criteria->getConditions(), $existing);
238
+		$criteria->setConditions($criteria->combine('&&', $expr));
239 239
 	}
240 240
 
241 241
 
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
246 246
 	 * @param array $params List of criteria data with condition, sorting and paging
247 247
 	 */
248
-	protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params )
248
+	protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params)
249 249
 	{
250
-		$start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 );
251
-		$size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 );
250
+		$start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0);
251
+		$size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25);
252 252
 
253
-		$criteria->setSlice( $start, $size );
253
+		$criteria->setSlice($start, $size);
254 254
 	}
255 255
 
256 256
 
@@ -260,24 +260,24 @@  discard block
 block discarded – undo
260 260
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
261 261
 	 * @param array $params List of criteria data with condition, sorting and paging
262 262
 	 */
263
-	protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params )
263
+	protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params)
264 264
 	{
265
-		if( !isset( $params['sort'] ) ) {
265
+		if (!isset($params['sort'])) {
266 266
 			return;
267 267
 		}
268 268
 
269 269
 		$sortation = array();
270 270
 
271
-		foreach( explode( ',', $params['sort'] ) as $sort )
271
+		foreach (explode(',', $params['sort']) as $sort)
272 272
 		{
273
-			if( $sort[0] === '-' ) {
274
-				$sortation[] = $criteria->sort( '-', substr( $sort, 1 ) );
273
+			if ($sort[0] === '-') {
274
+				$sortation[] = $criteria->sort('-', substr($sort, 1));
275 275
 			} else {
276
-				$sortation[] = $criteria->sort( '+', $sort );
276
+				$sortation[] = $criteria->sort('+', $sort);
277 277
 			}
278 278
 		}
279 279
 
280
-		$criteria->setSortations( $sortation );
280
+		$criteria->setSortations($sortation);
281 281
 	}
282 282
 
283 283
 
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 	 * @param \stdClass $request Object with request body data
289 289
 	 * @return array List of items
290 290
 	 */
291
-	protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request )
291
+	protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request)
292 292
 	{
293 293
 		$data = array();
294 294
 
295
-		if( isset( $request->data ) )
295
+		if (isset($request->data))
296 296
 		{
297
-			foreach( (array) $request->data as $entry ) {
298
-				$data[] = $this->saveEntry( $manager, $entry );
297
+			foreach ((array) $request->data as $entry) {
298
+				$data[] = $this->saveEntry($manager, $entry);
299 299
 			}
300 300
 		}
301 301
 
@@ -310,22 +310,22 @@  discard block
 block discarded – undo
310 310
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
311 311
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
312 312
 	 */
313
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
313
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
314 314
 	{
315
-		if( isset( $entry->id ) ) {
316
-			$item = $manager->getItem( $entry->id );
315
+		if (isset($entry->id)) {
316
+			$item = $manager->getItem($entry->id);
317 317
 		} else {
318 318
 			$item = $manager->createItem();
319 319
 		}
320 320
 
321
-		$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
322
-		$manager->saveItem( $item );
321
+		$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
322
+		$manager->saveItem($item);
323 323
 
324
-		if( isset( $entry->relationships ) ) {
325
-			$this->saveRelationships( $manager, $item, $entry->relationships );
324
+		if (isset($entry->relationships)) {
325
+			$this->saveRelationships($manager, $item, $entry->relationships);
326 326
 		}
327 327
 
328
-		return $manager->getItem( $item->getId() );
328
+		return $manager->getItem($item->getId());
329 329
 	}
330 330
 
331 331
 
@@ -336,28 +336,28 @@  discard block
 block discarded – undo
336 336
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set
337 337
 	 * @param \stdClass $relationships Object including the <domain>/data/attributes structure
338 338
 	 */
339
-	protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager,
340
-		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships )
339
+	protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager,
340
+		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships)
341 341
 	{
342 342
 		$id = $item->getId();
343
-		$listManager = $manager->getSubManager( 'lists' );
343
+		$listManager = $manager->getSubManager('lists');
344 344
 
345
-		foreach( (array) $relationships as $domain => $list )
345
+		foreach ((array) $relationships as $domain => $list)
346 346
 		{
347
-			if( isset( $list->data ) )
347
+			if (isset($list->data))
348 348
 			{
349
-				foreach( (array) $list->data as $data )
349
+				foreach ((array) $list->data as $data)
350 350
 				{
351
-					$listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain );
351
+					$listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain);
352 352
 
353
-					if( isset( $data->id ) ) {
354
-						$listItem->setRefId( $data->id );
353
+					if (isset($data->id)) {
354
+						$listItem->setRefId($data->id);
355 355
 					}
356 356
 
357
-					$listItem->setParentId( $id );
358
-					$listItem->setDomain( $domain );
357
+					$listItem->setParentId($id);
358
+					$listItem->setDomain($domain);
359 359
 
360
-					$listManager->saveItem( $listItem, false );
360
+					$listManager->saveItem($listItem, false);
361 361
 				}
362 362
 			}
363 363
 		}
@@ -374,20 +374,20 @@  discard block
 block discarded – undo
374 374
 	 * @return \Aimeos\MShop\Common\Item\Iface Item including the data
375 375
 	 */
376 376
 	protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager,
377
-		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain )
377
+		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain)
378 378
 	{
379
-		if( isset( $data->attributes ) )
379
+		if (isset($data->attributes))
380 380
 		{
381 381
 			$attr = (array) $data->attributes;
382
-			$key = str_replace( '/', '.', $item->getResourceType() );
382
+			$key = str_replace('/', '.', $item->getResourceType());
383 383
 
384
-			if( isset( $attr[$key.'.type'] ) )
384
+			if (isset($attr[$key . '.type']))
385 385
 			{
386
-				$typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain );
387
-				$attr[$key.'.typeid'] = $typeItem->getId();
386
+				$typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain);
387
+				$attr[$key . '.typeid'] = $typeItem->getId();
388 388
 			}
389 389
 
390
-			$item->fromArray( $attr );
390
+			$item->fromArray($attr);
391 391
 		}
392 392
 
393 393
 		return $item;
Please login to merge, or discard this patch.
admin/jsonadm/templates/partials/data-standard.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $options = 0;
4
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
4
+if (defined('JSON_PRETTY_PRINT')) {
5 5
 	$options = JSON_PRETTY_PRINT;
6 6
 }
7 7
 
8 8
 
9
-$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems )
9
+$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems)
10 10
 {
11 11
 	$id = $item->getId();
12 12
 	$attributes = $item->toArray();
13 13
 	$type = $item->getResourceType();
14
-	$params = array( 'resource' => $item->getResourceType(), 'id' => $id );
14
+	$params = array('resource' => $item->getResourceType(), 'id' => $id);
15 15
 
16
-	$target = $view->config( 'admin/jsonadm/url/target' );
17
-	$cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' );
18
-	$action = $view->config( 'admin/jsonadm/url/action', 'get' );
19
-	$config = $view->config( 'admin/jsonadm/url/config', array() );
16
+	$target = $view->config('admin/jsonadm/url/target');
17
+	$cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm');
18
+	$action = $view->config('admin/jsonadm/url/action', 'get');
19
+	$config = $view->config('admin/jsonadm/url/config', array());
20 20
 
21
-	if( isset( $fields[$type] ) ) {
22
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
21
+	if (isset($fields[$type])) {
22
+		$attributes = array_intersect_key($attributes, $fields[$type]);
23 23
 	}
24 24
 
25 25
 	$result = array(
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
 		'type' => $type,
28 28
 		'attributes' => $attributes,
29 29
 		'links' => array(
30
-			'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
30
+			'self' => $view->url($target, $cntl, $action, $params, array(), $config)
31 31
 		),
32 32
 		'relationships' => array()
33 33
 	);
34 34
 
35
-	foreach( $childItems as $childItem )
35
+	foreach ($childItems as $childItem)
36 36
 	{
37
-		if( $childItem->getParentId() == $id )
37
+		if ($childItem->getParentId() == $id)
38 38
 		{
39 39
 			$type = $childItem->getResourceType();
40
-			$result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) );
40
+			$result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type));
41 41
 		}
42 42
 	}
43 43
 
44
-	foreach( $listItems as $listId => $listItem )
44
+	foreach ($listItems as $listId => $listItem)
45 45
 	{
46
-		if( $listItem->getParentId() == $id )
46
+		if ($listItem->getParentId() == $id)
47 47
 		{
48 48
 			$type = $listItem->getDomain();
49
-			$params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId );
49
+			$params = array('resource' => $listItem->getResourceType(), 'id' => $listId);
50 50
 
51
-			$result['relationships'][$type][] = array( 'data' => array(
51
+			$result['relationships'][$type][] = array('data' => array(
52 52
 				'id' => $listItem->getRefId(), 'type' => $type,
53 53
 				'attributes' => $listItem->toArray(), 'links' => array(
54
-					'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
54
+					'self' => $view->url($target, $cntl, $action, $params, array(), $config)
55 55
 				)
56
-			) );
56
+			));
57 57
 		}
58 58
 	}
59 59
 
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
 };
62 62
 
63 63
 
64
-$fields = $this->param( 'fields', array() );
64
+$fields = $this->param('fields', array());
65 65
 
66
-foreach( (array) $fields as $resource => $list ) {
67
-	$fields[$resource] = array_flip( explode( ',', $list ) );
66
+foreach ((array) $fields as $resource => $list) {
67
+	$fields[$resource] = array_flip(explode(',', $list));
68 68
 }
69 69
 
70 70
 
71
-$data = $this->get( 'data', array() );
72
-$childItems = $this->get( 'childItems', array() );
73
-$listItems = $this->get( 'listItems', array() );
71
+$data = $this->get('data', array());
72
+$childItems = $this->get('childItems', array());
73
+$listItems = $this->get('listItems', array());
74 74
 
75
-if( is_array( $data ) )
75
+if (is_array($data))
76 76
 {
77 77
 	$response = array();
78 78
 
79
-	foreach( $data as $item ) {
80
-		$response[] = $build( $this, $item, $fields, $childItems, $listItems );
79
+	foreach ($data as $item) {
80
+		$response[] = $build($this, $item, $fields, $childItems, $listItems);
81 81
 	}
82 82
 }
83
-elseif( $data !== null )
83
+elseif ($data !== null)
84 84
 {
85
-	$response = $build( $this, $data, $fields, $childItems, $listItems );
85
+	$response = $build($this, $data, $fields, $childItems, $listItems);
86 86
 }
87 87
 else
88 88
 {
@@ -90,4 +90,4 @@  discard block
 block discarded – undo
90 90
 }
91 91
 
92 92
 
93
-echo json_encode( $response, $options );
94 93
\ No newline at end of file
94
+echo json_encode($response, $options);
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/templates/partials/order/data-standard.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $options = 0;
4
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
4
+if (defined('JSON_PRETTY_PRINT')) {
5 5
 	$options = JSON_PRETTY_PRINT;
6 6
 }
7 7
 
8
-$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems )
8
+$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems)
9 9
 {
10 10
 	$id = $item->getId();
11 11
 	$baseId = $item->getBaseId();
12 12
 	$attributes = $item->toArray();
13 13
 	$type = $item->getResourceType();
14
-	$params = array( 'resource' => $item->getResourceType(), 'id' => $id );
14
+	$params = array('resource' => $item->getResourceType(), 'id' => $id);
15 15
 
16
-	$target = $view->config( 'admin/jsonadm/url/target' );
17
-	$cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' );
18
-	$action = $view->config( 'admin/jsonadm/url/action', 'get' );
19
-	$config = $view->config( 'admin/jsonadm/url/config', array() );
16
+	$target = $view->config('admin/jsonadm/url/target');
17
+	$cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm');
18
+	$action = $view->config('admin/jsonadm/url/action', 'get');
19
+	$config = $view->config('admin/jsonadm/url/config', array());
20 20
 
21
-	if( isset( $fields[$type] ) ) {
22
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
21
+	if (isset($fields[$type])) {
22
+		$attributes = array_intersect_key($attributes, $fields[$type]);
23 23
 	}
24 24
 
25 25
 	$result = array(
@@ -27,25 +27,25 @@  discard block
 block discarded – undo
27 27
 		'type' => $type,
28 28
 		'attributes' => $attributes,
29 29
 		'links' => array(
30
-			'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
30
+			'self' => $view->url($target, $cntl, $action, $params, array(), $config)
31 31
 		),
32 32
 		'relationships' => array()
33 33
 	);
34 34
 
35
-	foreach( $childItems as $childId => $childItem )
35
+	foreach ($childItems as $childId => $childItem)
36 36
 	{
37
-		if( $childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id
37
+		if ($childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id
38 38
 			|| $childItem instanceof \Aimeos\MShop\Order\Item\Base\Iface && $childItem->getId() == $baseId
39 39
 		) {
40 40
 			$type = $childItem->getResourceType();
41
-			$params = array( 'resource' => $childItem->getResourceType(), 'id' => $childId );
41
+			$params = array('resource' => $childItem->getResourceType(), 'id' => $childId);
42 42
 
43
-			$result['relationships'][$type][] = array( 'data' => array(
43
+			$result['relationships'][$type][] = array('data' => array(
44 44
 				'id' => $childId, 'type' => $type,
45 45
 				'links' => array(
46
-					'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
46
+					'self' => $view->url($target, $cntl, $action, $params, array(), $config)
47 47
 				)
48
-			) );
48
+			));
49 49
 		}
50 50
 	}
51 51
 
@@ -53,27 +53,27 @@  discard block
 block discarded – undo
53 53
 };
54 54
 
55 55
 
56
-$fields = $this->param( 'fields', array() );
56
+$fields = $this->param('fields', array());
57 57
 
58
-foreach( (array) $fields as $resource => $list ) {
59
-	$fields[$resource] = array_flip( explode( ',', $list ) );
58
+foreach ((array) $fields as $resource => $list) {
59
+	$fields[$resource] = array_flip(explode(',', $list));
60 60
 }
61 61
 
62 62
 
63
-$data = $this->get( 'data', array() );
64
-$childItems = $this->get( 'childItems', array() );
63
+$data = $this->get('data', array());
64
+$childItems = $this->get('childItems', array());
65 65
 
66
-if( is_array( $data ) )
66
+if (is_array($data))
67 67
 {
68 68
 	$response = array();
69 69
 
70
-	foreach( $data as $item ) {
71
-		$response[] = $build( $this, $item, $fields, $childItems );
70
+	foreach ($data as $item) {
71
+		$response[] = $build($this, $item, $fields, $childItems);
72 72
 	}
73 73
 }
74
-elseif( $data !== null )
74
+elseif ($data !== null)
75 75
 {
76
-	$response = $build( $this, $data, $fields, $childItems );
76
+	$response = $build($this, $data, $fields, $childItems);
77 77
 }
78 78
 else
79 79
 {
@@ -81,4 +81,4 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 
84
-echo json_encode( $response, $options );
85 84
\ No newline at end of file
85
+echo json_encode($response, $options);
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/templates/partials/order/base/data-standard.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $options = 0;
4
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
4
+if (defined('JSON_PRETTY_PRINT')) {
5 5
 	$options = JSON_PRETTY_PRINT;
6 6
 }
7 7
 
8
-$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Base\Iface $item, array $fields, array $childItems )
8
+$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Base\Iface $item, array $fields, array $childItems)
9 9
 {
10 10
 	$id = $item->getId();
11 11
 	$attributes = $item->toArray();
12 12
 	$type = $item->getResourceType();
13
-	$params = array( 'resource' => $item->getResourceType(), 'id' => $id );
13
+	$params = array('resource' => $item->getResourceType(), 'id' => $id);
14 14
 
15
-	$target = $view->config( 'admin/jsonadm/url/target' );
16
-	$cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' );
17
-	$action = $view->config( 'admin/jsonadm/url/action', 'get' );
18
-	$config = $view->config( 'admin/jsonadm/url/config', array() );
15
+	$target = $view->config('admin/jsonadm/url/target');
16
+	$cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm');
17
+	$action = $view->config('admin/jsonadm/url/action', 'get');
18
+	$config = $view->config('admin/jsonadm/url/config', array());
19 19
 
20
-	if( isset( $fields[$type] ) ) {
21
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
20
+	if (isset($fields[$type])) {
21
+		$attributes = array_intersect_key($attributes, $fields[$type]);
22 22
 	}
23 23
 
24 24
 	$result = array(
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
 		'type' => $type,
27 27
 		'attributes' => $attributes,
28 28
 		'links' => array(
29
-			'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
29
+			'self' => $view->url($target, $cntl, $action, $params, array(), $config)
30 30
 		),
31 31
 		'relationships' => array()
32 32
 	);
33 33
 
34
-	foreach( $childItems as $childId => $childItem )
34
+	foreach ($childItems as $childId => $childItem)
35 35
 	{
36
-		if( $childItem->getBaseId() == $id )
36
+		if ($childItem->getBaseId() == $id)
37 37
 		{
38 38
 			$type = $childItem->getResourceType();
39
-			$params = array( 'resource' => $childItem->getResourceType(), 'id' => $childId );
39
+			$params = array('resource' => $childItem->getResourceType(), 'id' => $childId);
40 40
 
41
-			$result['relationships'][$type][] = array( 'data' => array(
41
+			$result['relationships'][$type][] = array('data' => array(
42 42
 				'id' => $childId, 'type' => $type, 'links' => array(
43
-					'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
43
+					'self' => $view->url($target, $cntl, $action, $params, array(), $config)
44 44
 				)
45
-			) );
45
+			));
46 46
 		}
47 47
 	}
48 48
 
@@ -50,27 +50,27 @@  discard block
 block discarded – undo
50 50
 };
51 51
 
52 52
 
53
-$fields = $this->param( 'fields', array() );
53
+$fields = $this->param('fields', array());
54 54
 
55
-foreach( (array) $fields as $resource => $list ) {
56
-	$fields[$resource] = array_flip( explode( ',', $list ) );
55
+foreach ((array) $fields as $resource => $list) {
56
+	$fields[$resource] = array_flip(explode(',', $list));
57 57
 }
58 58
 
59 59
 
60
-$data = $this->get( 'data', array() );
61
-$childItems = $this->get( 'childItems', array() );
60
+$data = $this->get('data', array());
61
+$childItems = $this->get('childItems', array());
62 62
 
63
-if( is_array( $data ) )
63
+if (is_array($data))
64 64
 {
65 65
 	$response = array();
66 66
 
67
-	foreach( $data as $item ) {
68
-		$response[] = $build( $this, $item, $fields, $childItems );
67
+	foreach ($data as $item) {
68
+		$response[] = $build($this, $item, $fields, $childItems);
69 69
 	}
70 70
 }
71
-elseif( $data !== null )
71
+elseif ($data !== null)
72 72
 {
73
-	$response = $build( $this, $data, $fields, $childItems );
73
+	$response = $build($this, $data, $fields, $childItems);
74 74
 }
75 75
 else
76 76
 {
@@ -78,4 +78,4 @@  discard block
 block discarded – undo
78 78
 }
79 79
 
80 80
 
81
-echo json_encode( $response, $options );
82 81
\ No newline at end of file
82
+echo json_encode($response, $options);
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/templates/partials/catalog/data-standard.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $options = 0;
4
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
4
+if (defined('JSON_PRETTY_PRINT')) {
5 5
 	$options = JSON_PRETTY_PRINT;
6 6
 }
7 7
 
8 8
 
9
-$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems )
9
+$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems)
10 10
 {
11 11
 	$id = $item->getId();
12 12
 	$attributes = $item->toArray();
13 13
 	$type = $item->getResourceType();
14
-	$params = array( 'resource' => $item->getResourceType(), 'id' => $id );
14
+	$params = array('resource' => $item->getResourceType(), 'id' => $id);
15 15
 
16
-	$target = $view->config( 'admin/jsonadm/url/target' );
17
-	$cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' );
18
-	$action = $view->config( 'admin/jsonadm/url/action', 'get' );
19
-	$config = $view->config( 'admin/jsonadm/url/config', array() );
16
+	$target = $view->config('admin/jsonadm/url/target');
17
+	$cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm');
18
+	$action = $view->config('admin/jsonadm/url/action', 'get');
19
+	$config = $view->config('admin/jsonadm/url/config', array());
20 20
 
21
-	if( isset( $fields[$type] ) ) {
22
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
21
+	if (isset($fields[$type])) {
22
+		$attributes = array_intersect_key($attributes, $fields[$type]);
23 23
 	}
24 24
 
25 25
 	$result = array(
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
 		'type' => $type,
28 28
 		'attributes' => $attributes,
29 29
 		'links' => array(
30
-			'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
30
+			'self' => $view->url($target, $cntl, $action, $params, array(), $config)
31 31
 		),
32 32
 		'relationships' => array()
33 33
 	);
34 34
 
35
-	foreach( $item->getChildren() as $childItem )
35
+	foreach ($item->getChildren() as $childItem)
36 36
 	{
37 37
 		$type = $childItem->getResourceType();
38
-		$result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) );
38
+		$result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type));
39 39
 	}
40 40
 
41
-	foreach( $listItems as $listId => $listItem )
41
+	foreach ($listItems as $listId => $listItem)
42 42
 	{
43
-		if( $listItem->getParentId() == $id )
43
+		if ($listItem->getParentId() == $id)
44 44
 		{
45 45
 			$type = $listItem->getDomain();
46
-			$params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId );
46
+			$params = array('resource' => $listItem->getResourceType(), 'id' => $listId);
47 47
 
48
-			$result['relationships'][$type][] = array( 'data' => array(
48
+			$result['relationships'][$type][] = array('data' => array(
49 49
 				'id' => $listItem->getRefId(), 'type' => $type,
50 50
 				'attributes' => $listItem->toArray(), 'links' => array(
51
-					'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
51
+					'self' => $view->url($target, $cntl, $action, $params, array(), $config)
52 52
 				)
53
-			) );
53
+			));
54 54
 		}
55 55
 	}
56 56
 
@@ -58,27 +58,27 @@  discard block
 block discarded – undo
58 58
 };
59 59
 
60 60
 
61
-$fields = $this->param( 'fields', array() );
61
+$fields = $this->param('fields', array());
62 62
 
63
-foreach( (array) $fields as $resource => $list ) {
64
-	$fields[$resource] = array_flip( explode( ',', $list ) );
63
+foreach ((array) $fields as $resource => $list) {
64
+	$fields[$resource] = array_flip(explode(',', $list));
65 65
 }
66 66
 
67 67
 
68
-$data = $this->get( 'data', array() );
69
-$listItems = $this->get( 'listItems', array() );
68
+$data = $this->get('data', array());
69
+$listItems = $this->get('listItems', array());
70 70
 
71
-if( is_array( $data ) )
71
+if (is_array($data))
72 72
 {
73 73
 	$response = array();
74 74
 
75
-	foreach( $data as $item ) {
76
-		$response[] = $build( $this, $item, $fields, $listItems );
75
+	foreach ($data as $item) {
76
+		$response[] = $build($this, $item, $fields, $listItems);
77 77
 	}
78 78
 }
79
-elseif( $data !== null )
79
+elseif ($data !== null)
80 80
 {
81
-	$response = $build( $this, $data, $fields, $listItems );
81
+	$response = $build($this, $data, $fields, $listItems);
82 82
 }
83 83
 else
84 84
 {
@@ -86,4 +86,4 @@  discard block
 block discarded – undo
86 86
 }
87 87
 
88 88
 
89
-echo json_encode( $response, $options );
90 89
\ No newline at end of file
90
+echo json_encode($response, $options);
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Catalog/Standard.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param integer &$status Variable which contains the HTTP status afterwards
109 109
 	 * @return string Content for response body
110 110
 	 */
111
-	public function get( $body, array &$header, &$status )
111
+	public function get($body, array &$header, &$status)
112 112
 	{
113 113
 		/** admin/jsonadm/partials/catalog/template-data
114 114
 		 * Relative path to the data partial template file for the catalog client
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 		 * @since 2016.07
126 126
 		 * @category Developer
127 127
 		 */
128
-		$this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) );
128
+		$this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data'));
129 129
 
130
-		return parent::get( $body, $header, $status );
130
+		return parent::get($body, $header, $status);
131 131
 	}
132 132
 
133 133
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	 * @param array $include List of resource types that should be fetched
139 139
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
140 140
 	 */
141
-	protected function getChildItems( array $items, array $include )
141
+	protected function getChildItems(array $items, array $include)
142 142
 	{
143 143
 		$list = array();
144 144
 
145
-		if( in_array( 'catalog', $include ) )
145
+		if (in_array('catalog', $include))
146 146
 		{
147
-			foreach( $items as $item ) {
148
-				$list = array_merge( $list, $item->getChildren() );
147
+			foreach ($items as $item) {
148
+				$list = array_merge($list, $item->getChildren());
149 149
 			}
150 150
 		}
151 151
 
@@ -159,27 +159,27 @@  discard block
 block discarded – undo
159 159
 	 * @param \Aimeos\MW\View\Iface $view View instance
160 160
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
161 161
 	 */
162
-	protected function getItems( \Aimeos\MW\View\Iface $view )
162
+	protected function getItems(\Aimeos\MW\View\Iface $view)
163 163
 	{
164
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() );
165
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' );
166
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
164
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : array());
165
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog');
166
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
167 167
 		$total = 1;
168 168
 
169
-		if( ( $id = $view->param( 'id' ) ) == null )
169
+		if (($id = $view->param('id')) == null)
170 170
 		{
171
-			$view->data = $manager->searchItems( $search, array(), $total );
172
-			$view->listItems = $this->getListItems( $view->data, $include );
173
-			$view->childItems = $this->getChildItems( $view->data, $include );
171
+			$view->data = $manager->searchItems($search, array(), $total);
172
+			$view->listItems = $this->getListItems($view->data, $include);
173
+			$view->childItems = $this->getChildItems($view->data, $include);
174 174
 		}
175 175
 		else
176 176
 		{
177
-			$view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search );
178
-			$view->listItems = $this->getListItems( array( $id => $view->data ), $include );
179
-			$view->childItems = $this->getChildItems( array( $view->data ), $include );
177
+			$view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search);
178
+			$view->listItems = $this->getListItems(array($id => $view->data), $include);
179
+			$view->childItems = $this->getChildItems(array($view->data), $include);
180 180
 		}
181 181
 
182
-		$view->refItems = $this->getRefItems( $view->listItems );
182
+		$view->refItems = $this->getRefItems($view->listItems);
183 183
 		$view->total = $total;
184 184
 
185 185
 		return $view;
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	 * @param array $include List of resource types that should be fetched
194 194
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
195 195
 	 */
196
-	protected function getListItems( array $items, array $include )
196
+	protected function getListItems(array $items, array $include)
197 197
 	{
198
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
198
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
199 199
 
200 200
 		$search = $manager->createSearch();
201 201
 		$expr = array(
202
-			$search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ),
203
-			$search->compare( '==', 'catalog.lists.domain', $include ),
202
+			$search->compare('==', 'catalog.lists.parentid', array_keys($items)),
203
+			$search->compare('==', 'catalog.lists.domain', $include),
204 204
 		);
205
-		$search->setConditions( $search->combine( '&&', $expr ) );
205
+		$search->setConditions($search->combine('&&', $expr));
206 206
 
207
-		return $manager->searchItems( $search );
207
+		return $manager->searchItems($search);
208 208
 	}
209 209
 
210 210
 
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
216 216
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
217 217
 	 */
218
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
218
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
219 219
 	{
220
-		$targetId = ( isset( $entry->targetid ) ? $entry->targetid : null );
221
-		$refId = ( isset( $entry->refid ) ? $entry->refid : null );
220
+		$targetId = (isset($entry->targetid) ? $entry->targetid : null);
221
+		$refId = (isset($entry->refid) ? $entry->refid : null);
222 222
 
223
-		if( isset( $entry->id ) )
223
+		if (isset($entry->id))
224 224
 		{
225
-			$item = $manager->getItem( $entry->id );
226
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
227
-			$manager->saveItem( $item );
225
+			$item = $manager->getItem($entry->id);
226
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
227
+			$manager->saveItem($item);
228 228
 
229
-			if( isset( $entry->parentid ) && $targetId !== null ) {
230
-				$manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId );
229
+			if (isset($entry->parentid) && $targetId !== null) {
230
+				$manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId);
231 231
 			}
232 232
 		}
233 233
 		else
234 234
 		{
235 235
 			$item = $manager->createItem();
236
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
237
-			$manager->insertItem( $item, $targetId, $refId );
236
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
237
+			$manager->insertItem($item, $targetId, $refId);
238 238
 		}
239 239
 
240
-		if( isset( $entry->relationships ) ) {
241
-			$this->saveRelationships( $manager, $item, $entry->relationships );
240
+		if (isset($entry->relationships)) {
241
+			$this->saveRelationships($manager, $item, $entry->relationships);
242 242
 		}
243 243
 
244
-		return $manager->getItem( $item->getId() );
244
+		return $manager->getItem($item->getId());
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/partials/locale/site/data-standard.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $options = 0;
4
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
4
+if (defined('JSON_PRETTY_PRINT')) {
5 5
 	$options = JSON_PRETTY_PRINT;
6 6
 }
7 7
 
8 8
 
9
-$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields )
9
+$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields)
10 10
 {
11 11
 	$id = $item->getId();
12 12
 	$attributes = $item->toArray();
13 13
 	$type = $item->getResourceType();
14
-	$params = array( 'resource' => $item->getResourceType(), 'id' => $id );
14
+	$params = array('resource' => $item->getResourceType(), 'id' => $id);
15 15
 
16
-	$target = $view->config( 'admin/jsonadm/url/target' );
17
-	$cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' );
18
-	$action = $view->config( 'admin/jsonadm/url/action', 'get' );
19
-	$config = $view->config( 'admin/jsonadm/url/config', array() );
16
+	$target = $view->config('admin/jsonadm/url/target');
17
+	$cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm');
18
+	$action = $view->config('admin/jsonadm/url/action', 'get');
19
+	$config = $view->config('admin/jsonadm/url/config', array());
20 20
 
21
-	if( isset( $fields[$type] ) ) {
22
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
21
+	if (isset($fields[$type])) {
22
+		$attributes = array_intersect_key($attributes, $fields[$type]);
23 23
 	}
24 24
 
25 25
 	$result = array(
@@ -27,41 +27,41 @@  discard block
 block discarded – undo
27 27
 		'type' => $type,
28 28
 		'attributes' => $attributes,
29 29
 		'links' => array(
30
-			'self' => $view->url( $target, $cntl, $action, $params, array(), $config )
30
+			'self' => $view->url($target, $cntl, $action, $params, array(), $config)
31 31
 		),
32 32
 		'relationships' => array()
33 33
 	);
34 34
 
35
-	foreach( $item->getChildren() as $childItem )
35
+	foreach ($item->getChildren() as $childItem)
36 36
 	{
37 37
 		$type = $childItem->getResourceType();
38
-		$result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) );
38
+		$result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type));
39 39
 	}
40 40
 
41 41
 	return $result;
42 42
 };
43 43
 
44 44
 
45
-$fields = $this->param( 'fields', array() );
45
+$fields = $this->param('fields', array());
46 46
 
47
-foreach( (array) $fields as $resource => $list ) {
48
-	$fields[$resource] = array_flip( explode( ',', $list ) );
47
+foreach ((array) $fields as $resource => $list) {
48
+	$fields[$resource] = array_flip(explode(',', $list));
49 49
 }
50 50
 
51 51
 
52
-$data = $this->get( 'data', array() );
52
+$data = $this->get('data', array());
53 53
 
54
-if( is_array( $data ) )
54
+if (is_array($data))
55 55
 {
56 56
 	$response = array();
57 57
 
58
-	foreach( $data as $item ) {
59
-		$response[] = $build( $this, $item, $fields );
58
+	foreach ($data as $item) {
59
+		$response[] = $build($this, $item, $fields);
60 60
 	}
61 61
 }
62
-elseif( $data !== null )
62
+elseif ($data !== null)
63 63
 {
64
-	$response = $build( $this, $data, $fields );
64
+	$response = $build($this, $data, $fields);
65 65
 }
66 66
 else
67 67
 {
@@ -69,4 +69,4 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 
72
-echo json_encode( $response, $options );
73 72
\ No newline at end of file
73
+echo json_encode($response, $options);
74 74
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Locale/Site/Standard.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param integer &$status Variable which contains the HTTP status afterwards
109 109
 	 * @return string Content for response body
110 110
 	 */
111
-	public function get( $body, array &$header, &$status )
111
+	public function get($body, array &$header, &$status)
112 112
 	{
113 113
 		/** admin/jsonadm/partials/locale/site/template-data
114 114
 		 * Relative path to the data partial template file for the locale site  client
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 		 * @since 2016.07
126 126
 		 * @category Developer
127 127
 		 */
128
-		$this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) );
128
+		$this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data'));
129 129
 
130
-		return parent::get( $body, $header, $status );
130
+		return parent::get($body, $header, $status);
131 131
 	}
132 132
 
133 133
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	 * @param array $include List of resource types that should be fetched
139 139
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
140 140
 	 */
141
-	protected function getChildItems( array $items, array $include )
141
+	protected function getChildItems(array $items, array $include)
142 142
 	{
143 143
 		$list = array();
144 144
 
145
-		if( in_array( 'locale/site', $include ) )
145
+		if (in_array('locale/site', $include))
146 146
 		{
147
-			foreach( $items as $item ) {
148
-				$list = array_merge( $list, $item->getChildren() );
147
+			foreach ($items as $item) {
148
+				$list = array_merge($list, $item->getChildren());
149 149
 			}
150 150
 		}
151 151
 
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
 	 * @param \Aimeos\MW\View\Iface $view View instance
160 160
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
161 161
 	 */
162
-	protected function getItems( \Aimeos\MW\View\Iface $view )
162
+	protected function getItems(\Aimeos\MW\View\Iface $view)
163 163
 	{
164
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() );
165
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' );
166
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
164
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : array());
165
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site');
166
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
167 167
 		$total = 1;
168 168
 
169
-		if( ( $id = $view->param( 'id' ) ) == null )
169
+		if (($id = $view->param('id')) == null)
170 170
 		{
171
-			$view->data = $manager->searchItems( $search, array(), $total );
172
-			$view->childItems = $this->getChildItems( $view->data, $include );
171
+			$view->data = $manager->searchItems($search, array(), $total);
172
+			$view->childItems = $this->getChildItems($view->data, $include);
173 173
 		}
174 174
 		else
175 175
 		{
176
-			$view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search );
177
-			$view->childItems = $this->getChildItems( array( $view->data ), $include );
176
+			$view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search);
177
+			$view->childItems = $this->getChildItems(array($view->data), $include);
178 178
 		}
179 179
 
180 180
 		$view->listItems = array();
@@ -192,32 +192,32 @@  discard block
 block discarded – undo
192 192
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
193 193
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
194 194
 	 */
195
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
195
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
196 196
 	{
197
-		$targetId = ( isset( $entry->targetid ) ? $entry->targetid : null );
198
-		$refId = ( isset( $entry->refid ) ? $entry->refid : null );
197
+		$targetId = (isset($entry->targetid) ? $entry->targetid : null);
198
+		$refId = (isset($entry->refid) ? $entry->refid : null);
199 199
 
200
-		if( isset( $entry->id ) )
200
+		if (isset($entry->id))
201 201
 		{
202
-			$item = $manager->getItem( $entry->id );
203
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
204
-			$manager->saveItem( $item );
202
+			$item = $manager->getItem($entry->id);
203
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
204
+			$manager->saveItem($item);
205 205
 
206
-			if( isset( $entry->parentid ) && $targetId !== null ) {
207
-				$manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId );
206
+			if (isset($entry->parentid) && $targetId !== null) {
207
+				$manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId);
208 208
 			}
209 209
 		}
210 210
 		else
211 211
 		{
212 212
 			$item = $manager->createItem();
213
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
214
-			$manager->insertItem( $item, $targetId, $refId );
213
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
214
+			$manager->insertItem($item, $targetId, $refId);
215 215
 		}
216 216
 
217
-		if( isset( $entry->relationships ) ) {
218
-			$this->saveRelationships( $manager, $item, $entry->relationships );
217
+		if (isset($entry->relationships)) {
218
+			$this->saveRelationships($manager, $item, $entry->relationships);
219 219
 		}
220 220
 
221
-		return $manager->getItem( $item->getId() );
221
+		return $manager->getItem($item->getId());
222 222
 	}
223 223
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Order/StandardTest.php 1 patch
Spacing   +39 added lines, -39 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\Order\Standard( $this->context, $this->view, $templatePaths, 'order' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Order\Standard($this->context, $this->view, $templatePaths, 'order');
26 26
 	}
27 27
 
28 28
 
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$params = array(
32 32
 			'filter' => array(
33
-				'==' => array( 'order.editor' => 'core:unittest' )
33
+				'==' => array('order.editor' => 'core:unittest')
34 34
 			),
35 35
 			'aggregate' => 'order.cdate',
36 36
 		);
37
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
38
-		$this->view->addHelper( 'param', $helper );
37
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
38
+		$this->view->addHelper('param', $helper);
39 39
 
40 40
 		$header = array();
41 41
 		$status = 500;
42 42
 
43
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
43
+		$result = json_decode($this->object->get('', $header, $status), true);
44 44
 
45
-		$this->assertEquals( 200, $status );
46
-		$this->assertEquals( 1, count( $header ) );
47
-		$this->assertEquals( 1, $result['meta']['total'] );
48
-		$this->assertEquals( 1, count( $result['data'] ) );
49
-		$this->assertEquals( 'aggregate', $result['data'][0]['type'] );
50
-		$this->assertGreaterThan( 0, count( $result['data'][0]['attributes'] ) );
51
-		$this->assertArrayNotHasKey( 'errors', $result );
45
+		$this->assertEquals(200, $status);
46
+		$this->assertEquals(1, count($header));
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals(1, count($result['data']));
49
+		$this->assertEquals('aggregate', $result['data'][0]['type']);
50
+		$this->assertGreaterThan(0, count($result['data'][0]['attributes']));
51
+		$this->assertArrayNotHasKey('errors', $result);
52 52
 	}
53 53
 
54 54
 
@@ -56,27 +56,27 @@  discard block
 block discarded – undo
56 56
 	{
57 57
 		$params = array(
58 58
 			'filter' => array(
59
-				'==' => array( 'order.datepayment' => '2008-02-15 12:34:56' )
59
+				'==' => array('order.datepayment' => '2008-02-15 12:34:56')
60 60
 			),
61 61
 			'include' => 'order/base,order/status'
62 62
 		);
63
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
64
-		$this->view->addHelper( 'param', $helper );
63
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
64
+		$this->view->addHelper('param', $helper);
65 65
 
66 66
 		$header = array();
67 67
 		$status = 500;
68 68
 
69
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
70
-
71
-		$this->assertEquals( 200, $status );
72
-		$this->assertEquals( 1, count( $header ) );
73
-		$this->assertEquals( 1, $result['meta']['total'] );
74
-		$this->assertEquals( 1, count( $result['data'] ) );
75
-		$this->assertEquals( 'order', $result['data'][0]['type'] );
76
-		$this->assertEquals( 3, count( $result['data'][0]['relationships']['order/status'] ) );
77
-		$this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base'] ) );
78
-		$this->assertEquals( 4, count( $result['included'] ) );
79
-		$this->assertArrayNotHasKey( 'errors', $result );
69
+		$result = json_decode($this->object->get('', $header, $status), true);
70
+
71
+		$this->assertEquals(200, $status);
72
+		$this->assertEquals(1, count($header));
73
+		$this->assertEquals(1, $result['meta']['total']);
74
+		$this->assertEquals(1, count($result['data']));
75
+		$this->assertEquals('order', $result['data'][0]['type']);
76
+		$this->assertEquals(3, count($result['data'][0]['relationships']['order/status']));
77
+		$this->assertEquals(1, count($result['data'][0]['relationships']['order/base']));
78
+		$this->assertEquals(4, count($result['included']));
79
+		$this->assertArrayNotHasKey('errors', $result);
80 80
 	}
81 81
 
82 82
 
@@ -89,22 +89,22 @@  discard block
 block discarded – undo
89 89
 			'sort' => 'order.id',
90 90
 			'include' => 'order/status'
91 91
 		);
92
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
93
-		$this->view->addHelper( 'param', $helper );
92
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
93
+		$this->view->addHelper('param', $helper);
94 94
 
95 95
 		$header = array();
96 96
 		$status = 500;
97 97
 
98
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
99
-
100
-		$this->assertEquals( 200, $status );
101
-		$this->assertEquals( 1, count( $header ) );
102
-		$this->assertGreaterThanOrEqual( 4, $result['meta']['total'] );
103
-		$this->assertGreaterThanOrEqual( 4, count( $result['data'] ) );
104
-		$this->assertEquals( 'order', $result['data'][0]['type'] );
105
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
106
-		$this->assertGreaterThanOrEqual( 3, count( $result['data'][0]['relationships']['order/status'] ) );
107
-		$this->assertGreaterThanOrEqual( 11, count( $result['included'] ) );
108
-		$this->assertArrayNotHasKey( 'errors', $result );
98
+		$result = json_decode($this->object->get('', $header, $status), true);
99
+
100
+		$this->assertEquals(200, $status);
101
+		$this->assertEquals(1, count($header));
102
+		$this->assertGreaterThanOrEqual(4, $result['meta']['total']);
103
+		$this->assertGreaterThanOrEqual(4, count($result['data']));
104
+		$this->assertEquals('order', $result['data'][0]['type']);
105
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
106
+		$this->assertGreaterThanOrEqual(3, count($result['data'][0]['relationships']['order/status']));
107
+		$this->assertGreaterThanOrEqual(11, count($result['included']));
108
+		$this->assertArrayNotHasKey('errors', $result);
109 109
 	}
110 110
 }
Please login to merge, or discard this patch.