@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Standard( $this->context, $this->view, $templatePaths, 'coupon' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Standard($this->context, $this->view, $templatePaths, 'coupon'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,27 +30,27 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'coupon.code.code' => '90AB' ) |
|
33 | + '==' => array('coupon.code.code' => '90AB') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'coupon/code' |
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 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'coupon', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['coupon/code'] ) ); |
|
51 | - $this->assertEquals( 1, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('coupon', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(1, count($result['data'][0]['relationships']['coupon/code'])); |
|
51 | + $this->assertEquals(1, count($result['included'])); |
|
52 | 52 | |
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -63,22 +63,22 @@ discard block |
||
63 | 63 | 'sort' => 'coupon.id', |
64 | 64 | 'include' => 'coupon/code' |
65 | 65 | ); |
66 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
67 | - $this->view->addHelper( 'param', $helper ); |
|
66 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
67 | + $this->view->addHelper('param', $helper); |
|
68 | 68 | |
69 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
70 | - $result = json_decode( (string) $response->getBody(), true ); |
|
69 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
70 | + $result = json_decode((string) $response->getBody(), true); |
|
71 | 71 | |
72 | 72 | |
73 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
74 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
73 | + $this->assertEquals(200, $response->getStatusCode()); |
|
74 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
75 | 75 | |
76 | - $this->assertEquals( 5, $result['meta']['total'] ); |
|
77 | - $this->assertEquals( 5, count( $result['data'] ) ); |
|
78 | - $this->assertEquals( 'coupon', $result['data'][0]['type'] ); |
|
79 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
80 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['coupon/code'] ) ); |
|
81 | - $this->assertEquals( 5, count( $result['included'] ) ); |
|
82 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
76 | + $this->assertEquals(5, $result['meta']['total']); |
|
77 | + $this->assertEquals(5, count($result['data'])); |
|
78 | + $this->assertEquals('coupon', $result['data'][0]['type']); |
|
79 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
80 | + $this->assertEquals(1, count($result['data'][0]['relationships']['coupon/code'])); |
|
81 | + $this->assertEquals(5, count($result['included'])); |
|
82 | + $this->assertArrayNotHasKey('errors', $result); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Customer\Standard( $this->context, $this->view, $templatePaths, 'customer' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Customer\Standard($this->context, $this->view, $templatePaths, 'customer'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'customer.code' => 'UTC001' ) |
|
33 | + '==' => array('customer.code' => 'UTC001') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text,customer/address' |
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 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'customer', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['customer/address'] ) ); |
|
52 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('customer', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(1, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertEquals(1, count($result['data'][0]['relationships']['customer/address'])); |
|
52 | + $this->assertEquals(2, count($result['included'])); |
|
53 | 53 | |
54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
54 | + $this->assertArrayNotHasKey('errors', $result); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $params = array( |
61 | 61 | 'filter' => array( |
62 | - '=~' => array( 'customer.code' => 'UTC' ) |
|
62 | + '=~' => array('customer.code' => 'UTC') |
|
63 | 63 | ), |
64 | 64 | 'fields' => array( |
65 | 65 | 'customer' => 'customer.id,customer.label' |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | 'sort' => 'customer.id', |
68 | 68 | 'include' => 'customer/address' |
69 | 69 | ); |
70 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
71 | - $this->view->addHelper( 'param', $helper ); |
|
70 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
71 | + $this->view->addHelper('param', $helper); |
|
72 | 72 | |
73 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
74 | - $result = json_decode( (string) $response->getBody(), true ); |
|
73 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
74 | + $result = json_decode((string) $response->getBody(), true); |
|
75 | 75 | |
76 | 76 | |
77 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
78 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
77 | + $this->assertEquals(200, $response->getStatusCode()); |
|
78 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
79 | 79 | |
80 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
81 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
82 | - $this->assertEquals( 'customer', $result['data'][0]['type'] ); |
|
83 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
84 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['customer/address'] ) ); |
|
85 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
80 | + $this->assertEquals(3, $result['meta']['total']); |
|
81 | + $this->assertEquals(3, count($result['data'])); |
|
82 | + $this->assertEquals('customer', $result['data'][0]['type']); |
|
83 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
84 | + $this->assertEquals(1, count($result['data'][0]['relationships']['customer/address'])); |
|
85 | + $this->assertEquals(4, count($result['included'])); |
|
86 | 86 | |
87 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
87 | + $this->assertArrayNotHasKey('errors', $result); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Text\Standard( $this->context, $this->view, $templatePaths, 'text' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Text\Standard($this->context, $this->view, $templatePaths, 'text'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'text.label' => 'misc_long_desc' ) |
|
33 | + '==' => array('text.label' => 'misc_long_desc') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'media' |
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 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'text', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 4, count( $result['data'][0]['relationships']['media'] ) ); |
|
51 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('text', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(4, count($result['data'][0]['relationships']['media'])); |
|
51 | + $this->assertEquals(4, count($result['included'])); |
|
52 | 52 | |
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -79,12 +79,10 @@ |
||
79 | 79 | foreach( $data as $item ) { |
80 | 80 | $response[] = $build( $this, $item, $fields, $childItems, $listItems ); |
81 | 81 | } |
82 | -} |
|
83 | -elseif( $data !== null ) |
|
82 | +} elseif( $data !== null ) |
|
84 | 83 | { |
85 | 84 | $response = $build( $this, $data, $fields, $childItems, $listItems ); |
86 | -} |
|
87 | -else |
|
85 | +} else |
|
88 | 86 | { |
89 | 87 | $response = null; |
90 | 88 | } |
@@ -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', [] ); |
|
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', []); |
|
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, [], $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, [], $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => [] |
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, [], $config ) |
|
54 | + 'self' => $view->url($target, $cntl, $action, $params, [], $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', [] ); |
|
64 | +$fields = $this->param('fields', []); |
|
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', [] ); |
|
72 | -$childItems = $this->get( 'childItems', [] ); |
|
73 | -$listItems = $this->get( 'listItems', [] ); |
|
71 | +$data = $this->get('data', []); |
|
72 | +$childItems = $this->get('childItems', []); |
|
73 | +$listItems = $this->get('listItems', []); |
|
74 | 74 | |
75 | -if( is_array( $data ) ) |
|
75 | +if (is_array($data)) |
|
76 | 76 | { |
77 | 77 | $response = []; |
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 |
@@ -67,12 +67,10 @@ |
||
67 | 67 | foreach( $data as $item ) { |
68 | 68 | $response[] = $build( $this, $item, $fields, $childItems ); |
69 | 69 | } |
70 | -} |
|
71 | -elseif( $data !== null ) |
|
70 | +} elseif( $data !== null ) |
|
72 | 71 | { |
73 | 72 | $response = $build( $this, $data, $fields, $childItems ); |
74 | -} |
|
75 | -else |
|
73 | +} else |
|
76 | 74 | { |
77 | 75 | $response = null; |
78 | 76 | } |
@@ -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', [] ); |
|
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', []); |
|
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, [], $config ) |
|
29 | + 'self' => $view->url($target, $cntl, $action, $params, [], $config) |
|
30 | 30 | ), |
31 | 31 | 'relationships' => [] |
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, [], $config ) |
|
43 | + 'self' => $view->url($target, $cntl, $action, $params, [], $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', [] ); |
|
53 | +$fields = $this->param('fields', []); |
|
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', [] ); |
|
61 | -$childItems = $this->get( 'childItems', [] ); |
|
60 | +$data = $this->get('data', []); |
|
61 | +$childItems = $this->get('childItems', []); |
|
62 | 62 | |
63 | -if( is_array( $data ) ) |
|
63 | +if (is_array($data)) |
|
64 | 64 | { |
65 | 65 | $response = []; |
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 |
@@ -58,12 +58,10 @@ |
||
58 | 58 | foreach( $data as $item ) { |
59 | 59 | $response[] = $build( $this, $item, $fields ); |
60 | 60 | } |
61 | -} |
|
62 | -elseif( $data !== null ) |
|
61 | +} elseif( $data !== null ) |
|
63 | 62 | { |
64 | 63 | $response = $build( $this, $data, $fields ); |
65 | -} |
|
66 | -else |
|
64 | +} else |
|
67 | 65 | { |
68 | 66 | $response = null; |
69 | 67 | } |
@@ -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\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', [] ); |
|
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', []); |
|
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 |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, [], $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, [], $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => [] |
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', [] ); |
|
45 | +$fields = $this->param('fields', []); |
|
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', [] ); |
|
52 | +$data = $this->get('data', []); |
|
53 | 53 | |
54 | -if( is_array( $data ) ) |
|
54 | +if (is_array($data)) |
|
55 | 55 | { |
56 | 56 | $response = []; |
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 |
||
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 |
@@ -75,12 +75,10 @@ |
||
75 | 75 | foreach( $data as $item ) { |
76 | 76 | $response[] = $build( $this, $item, $fields, $listItems ); |
77 | 77 | } |
78 | -} |
|
79 | -elseif( $data !== null ) |
|
78 | +} elseif( $data !== null ) |
|
80 | 79 | { |
81 | 80 | $response = $build( $this, $data, $fields, $listItems ); |
82 | -} |
|
83 | -else |
|
81 | +} else |
|
84 | 82 | { |
85 | 83 | $response = null; |
86 | 84 | } |
@@ -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\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', [] ); |
|
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', []); |
|
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 |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, [], $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, [], $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => [] |
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, [], $config ) |
|
51 | + 'self' => $view->url($target, $cntl, $action, $params, [], $config) |
|
52 | 52 | ) |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -58,27 +58,27 @@ discard block |
||
58 | 58 | }; |
59 | 59 | |
60 | 60 | |
61 | -$fields = $this->param( 'fields', [] ); |
|
61 | +$fields = $this->param('fields', []); |
|
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', [] ); |
|
69 | -$listItems = $this->get( 'listItems', [] ); |
|
68 | +$data = $this->get('data', []); |
|
69 | +$listItems = $this->get('listItems', []); |
|
70 | 70 | |
71 | -if( is_array( $data ) ) |
|
71 | +if (is_array($data)) |
|
72 | 72 | { |
73 | 73 | $response = []; |
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 |
||
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 |
@@ -1,12 +1,12 @@ |
||
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 | } |
@@ -28,6 +28,6 @@ |
||
28 | 28 | * @param array $templatePaths List of file system paths where the templates are stored |
29 | 29 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
30 | 30 | */ |
31 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, |
|
32 | - array $templatePaths, $path ); |
|
31 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, |
|
32 | + array $templatePaths, $path); |
|
33 | 33 | } |