@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,33 +27,33 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $childItems as $childItem ) |
|
35 | + foreach ($childItems as $childItem) |
|
36 | 36 | { |
37 | - if( $childItem->getParentId() == $id ) |
|
37 | + if ($childItem->getParentId() == $id) |
|
38 | 38 | { |
39 | 39 | $type = $childItem->getResourceType(); |
40 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
40 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach( $listItems as $listId => $listItem ) |
|
44 | + foreach ($listItems as $listId => $listItem) |
|
45 | 45 | { |
46 | - if( $listItem->getParentId() == $id ) |
|
46 | + if ($listItem->getParentId() == $id) |
|
47 | 47 | { |
48 | 48 | $type = $listItem->getDomain(); |
49 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
49 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
50 | 50 | |
51 | - $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 |
||
61 | 61 | }; |
62 | 62 | |
63 | 63 | |
64 | -$fields = $this->param( 'fields', array() ); |
|
64 | +$fields = $this->param('fields', array()); |
|
65 | 65 | |
66 | -foreach( (array) $fields as $resource => $list ) { |
|
67 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
66 | +foreach ((array) $fields as $resource => $list) { |
|
67 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | -$data = $this->get( 'data', array() ); |
|
72 | -$childItems = $this->get( 'childItems', array() ); |
|
73 | -$listItems = $this->get( 'listItems', array() ); |
|
71 | +$data = $this->get('data', array()); |
|
72 | +$childItems = $this->get('childItems', array()); |
|
73 | +$listItems = $this->get('listItems', array()); |
|
74 | 74 | |
75 | -if( is_array( $data ) ) |
|
75 | +if (is_array($data)) |
|
76 | 76 | { |
77 | 77 | $response = array(); |
78 | 78 | |
79 | - foreach( $data as $item ) { |
|
80 | - $response[] = $build( $this, $item, $fields, $childItems, $listItems ); |
|
79 | + foreach ($data as $item) { |
|
80 | + $response[] = $build($this, $item, $fields, $childItems, $listItems); |
|
81 | 81 | } |
82 | 82 | } |
83 | -elseif( $data !== null ) |
|
83 | +elseif ($data !== null) |
|
84 | 84 | { |
85 | - $response = $build( $this, $data, $fields, $childItems, $listItems ); |
|
85 | + $response = $build($this, $data, $fields, $childItems, $listItems); |
|
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
@@ -90,4 +90,4 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | -echo json_encode( $response, $options ); |
|
94 | 93 | \ No newline at end of file |
94 | +echo json_encode($response, $options); |
|
95 | 95 | \ No newline at end of file |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$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 |
||
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 |
||
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 |
||
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 |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$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 |
||
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 |
||
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 |
||
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 |