@@ -22,61 +22,61 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Product\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Product\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testAggregateAttribute() |
30 | 30 | { |
31 | - $params = array( 'aggregate' => 'index.attribute.id' ); |
|
32 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
33 | - $this->view->addHelper( 'param', $helper ); |
|
31 | + $params = array('aggregate' => 'index.attribute.id'); |
|
32 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
33 | + $this->view->addHelper('param', $helper); |
|
34 | 34 | |
35 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
36 | - $result = json_decode( (string) $response->getBody(), true ); |
|
35 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
36 | + $result = json_decode((string) $response->getBody(), true); |
|
37 | 37 | |
38 | 38 | |
39 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
40 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
41 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
39 | + $this->assertEquals(200, $response->getStatusCode()); |
|
40 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
41 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
42 | 42 | |
43 | - $this->assertEquals( 13, $result['meta']['total'] ); |
|
44 | - $this->assertEquals( 13, count( $result['data'] ) ); |
|
45 | - $this->assertGreaterThan( 0, $result['data'][0]['id'] ); |
|
46 | - $this->assertGreaterThan( 0, $result['data'][0]['attributes'] ); |
|
47 | - $this->assertEquals( 'index.attribute.id', $result['data'][0]['type'] ); |
|
43 | + $this->assertEquals(13, $result['meta']['total']); |
|
44 | + $this->assertEquals(13, count($result['data'])); |
|
45 | + $this->assertGreaterThan(0, $result['data'][0]['id']); |
|
46 | + $this->assertGreaterThan(0, $result['data'][0]['attributes']); |
|
47 | + $this->assertEquals('index.attribute.id', $result['data'][0]['type']); |
|
48 | 48 | |
49 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
49 | + $this->assertArrayNotHasKey('errors', $result); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testAggregateCatalog() |
54 | 54 | { |
55 | - $params = array( 'aggregate' => 'index.catalog.id' ); |
|
56 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
57 | - $this->view->addHelper( 'param', $helper ); |
|
55 | + $params = array('aggregate' => 'index.catalog.id'); |
|
56 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
57 | + $this->view->addHelper('param', $helper); |
|
58 | 58 | |
59 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
60 | - $result = json_decode( (string) $response->getBody(), true ); |
|
59 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
60 | + $result = json_decode((string) $response->getBody(), true); |
|
61 | 61 | |
62 | 62 | |
63 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
64 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
65 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
63 | + $this->assertEquals(200, $response->getStatusCode()); |
|
64 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
65 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
66 | 66 | |
67 | - $this->assertEquals( 4, $result['meta']['total'] ); |
|
68 | - $this->assertEquals( 4, count( $result['data'] ) ); |
|
69 | - $this->assertGreaterThan( 0, $result['data'][0]['id'] ); |
|
70 | - $this->assertGreaterThan( 0, $result['data'][0]['attributes'] ); |
|
71 | - $this->assertEquals( 'index.catalog.id', $result['data'][0]['type'] ); |
|
67 | + $this->assertEquals(4, $result['meta']['total']); |
|
68 | + $this->assertEquals(4, count($result['data'])); |
|
69 | + $this->assertGreaterThan(0, $result['data'][0]['id']); |
|
70 | + $this->assertGreaterThan(0, $result['data'][0]['attributes']); |
|
71 | + $this->assertEquals('index.catalog.id', $result['data'][0]['type']); |
|
72 | 72 | |
73 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
73 | + $this->assertArrayNotHasKey('errors', $result); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | 77 | public function testGetItem() |
78 | 78 | { |
79 | - $prodId = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNE' )->getId(); |
|
79 | + $prodId = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNE')->getId(); |
|
80 | 80 | $params = array( |
81 | 81 | 'id' => $prodId, |
82 | 82 | 'fields' => array( |
@@ -86,88 +86,88 @@ discard block |
||
86 | 86 | 'include' => 'attribute,media,price,product,product/property,text' |
87 | 87 | ); |
88 | 88 | |
89 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
90 | - $this->view->addHelper( 'param', $helper ); |
|
89 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
90 | + $this->view->addHelper('param', $helper); |
|
91 | 91 | |
92 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
93 | - $result = json_decode( (string) $response->getBody(), true ); |
|
92 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
93 | + $result = json_decode((string) $response->getBody(), true); |
|
94 | 94 | |
95 | 95 | |
96 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
97 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
98 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
96 | + $this->assertEquals(200, $response->getStatusCode()); |
|
97 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
98 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
99 | 99 | |
100 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
101 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
102 | - $this->assertEquals( 6, count( $result['data']['attributes']['text'] ) ); |
|
103 | - $this->assertEquals( 2, count( $result['data']['attributes']['price'] ) ); |
|
104 | - $this->assertEquals( 4, count( $result['data']['attributes']['media'] ) ); |
|
105 | - $this->assertEquals( 4, count( $result['data']['attributes']['product/property'] ) ); |
|
106 | - $this->assertEquals( 5, count( $result['data']['relationships']['product']['data'] ) ); |
|
107 | - $this->assertEquals( 5, count( $result['data']['relationships']['attribute']['data'] ) ); |
|
108 | - $this->assertEquals( 12, count( $result['included'] ) ); |
|
109 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
100 | + $this->assertEquals(1, $result['meta']['total']); |
|
101 | + $this->assertEquals('product', $result['data']['type']); |
|
102 | + $this->assertEquals(6, count($result['data']['attributes']['text'])); |
|
103 | + $this->assertEquals(2, count($result['data']['attributes']['price'])); |
|
104 | + $this->assertEquals(4, count($result['data']['attributes']['media'])); |
|
105 | + $this->assertEquals(4, count($result['data']['attributes']['product/property'])); |
|
106 | + $this->assertEquals(5, count($result['data']['relationships']['product']['data'])); |
|
107 | + $this->assertEquals(5, count($result['data']['relationships']['attribute']['data'])); |
|
108 | + $this->assertEquals(12, count($result['included'])); |
|
109 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
110 | 110 | |
111 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
111 | + $this->assertArrayNotHasKey('errors', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testGetItems() |
116 | 116 | { |
117 | - $catId = \Aimeos\MShop\Factory::createManager( $this->context, 'catalog' )->findItem( 'cafe' )->getId(); |
|
117 | + $catId = \Aimeos\MShop\Factory::createManager($this->context, 'catalog')->findItem('cafe')->getId(); |
|
118 | 118 | $params = array( |
119 | - 'filter' => array( 'f_catid' => $catId ), |
|
119 | + 'filter' => array('f_catid' => $catId), |
|
120 | 120 | 'fields' => array( |
121 | 121 | 'product' => 'product.id,product.label' |
122 | 122 | ), |
123 | 123 | 'sort' => '-product.id', |
124 | 124 | 'include' => 'attribute,text,product,product/property' |
125 | 125 | ); |
126 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
127 | - $this->view->addHelper( 'param', $helper ); |
|
128 | - |
|
129 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
130 | - $result = json_decode( (string) $response->getBody(), true ); |
|
131 | - |
|
132 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
133 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
134 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
135 | - |
|
136 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
137 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
138 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
139 | - $this->assertEquals( 4, count( $result['data'][0]['attributes'] ) ); |
|
140 | - $this->assertEquals( 6, count( $result['data'][0]['attributes']['text'] ) ); |
|
141 | - $this->assertEquals( 4, count( $result['data'][0]['attributes']['product/property'] ) ); |
|
142 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['attribute']['data'] ) ); |
|
143 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product']['data'] ) ); |
|
144 | - $this->assertEquals( 24, count( $result['included'] ) ); |
|
145 | - |
|
146 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
126 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
127 | + $this->view->addHelper('param', $helper); |
|
128 | + |
|
129 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
130 | + $result = json_decode((string) $response->getBody(), true); |
|
131 | + |
|
132 | + $this->assertEquals(200, $response->getStatusCode()); |
|
133 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
134 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
135 | + |
|
136 | + $this->assertEquals(2, $result['meta']['total']); |
|
137 | + $this->assertEquals(2, count($result['data'])); |
|
138 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
139 | + $this->assertEquals(4, count($result['data'][0]['attributes'])); |
|
140 | + $this->assertEquals(6, count($result['data'][0]['attributes']['text'])); |
|
141 | + $this->assertEquals(4, count($result['data'][0]['attributes']['product/property'])); |
|
142 | + $this->assertEquals(5, count($result['data'][0]['relationships']['attribute']['data'])); |
|
143 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product']['data'])); |
|
144 | + $this->assertEquals(24, count($result['included'])); |
|
145 | + |
|
146 | + $this->assertArrayNotHasKey('errors', $result); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | 150 | public function testGetItemsCriteria() |
151 | 151 | { |
152 | - $catId = \Aimeos\MShop\Factory::createManager( $this->context, 'catalog' )->findItem( 'cafe' )->getId(); |
|
152 | + $catId = \Aimeos\MShop\Factory::createManager($this->context, 'catalog')->findItem('cafe')->getId(); |
|
153 | 153 | $params = array( |
154 | 154 | 'filter' => array( |
155 | 155 | 'f_catid' => $catId, |
156 | 156 | 'f_search' => 'Cafe', |
157 | 157 | 'f_listtype' => ['unittype13', 'unittype19'], |
158 | - '==' => array( 'product.type.code' => 'default' ), |
|
158 | + '==' => array('product.type.code' => 'default'), |
|
159 | 159 | ), |
160 | 160 | 'sort' => '-product.id', |
161 | 161 | ); |
162 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
163 | - $this->view->addHelper( 'param', $helper ); |
|
162 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
163 | + $this->view->addHelper('param', $helper); |
|
164 | 164 | |
165 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
166 | - $result = json_decode( (string) $response->getBody(), true ); |
|
165 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
166 | + $result = json_decode((string) $response->getBody(), true); |
|
167 | 167 | |
168 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
169 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
170 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
168 | + $this->assertEquals(200, $response->getStatusCode()); |
|
169 | + $this->assertEquals(2, $result['meta']['total']); |
|
170 | + $this->assertArrayNotHasKey('errors', $result); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -175,21 +175,21 @@ discard block |
||
175 | 175 | { |
176 | 176 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
177 | 177 | |
178 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Product\Standard' ) |
|
179 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'product'] ) |
|
180 | - ->setMethods( ['getItems'] ) |
|
178 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Product\Standard') |
|
179 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'product']) |
|
180 | + ->setMethods(['getItems']) |
|
181 | 181 | ->getMock(); |
182 | 182 | |
183 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
184 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
183 | + $object->expects($this->once())->method('getItems') |
|
184 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
185 | 185 | |
186 | 186 | |
187 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
188 | - $result = json_decode( (string) $response->getBody(), true ); |
|
187 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
188 | + $result = json_decode((string) $response->getBody(), true); |
|
189 | 189 | |
190 | 190 | |
191 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
192 | - $this->assertArrayHasKey( 'errors', $result ); |
|
191 | + $this->assertEquals(404, $response->getStatusCode()); |
|
192 | + $this->assertArrayHasKey('errors', $result); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | { |
198 | 198 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
199 | 199 | |
200 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Product\Standard' ) |
|
201 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'product'] ) |
|
202 | - ->setMethods( ['getItems'] ) |
|
200 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Product\Standard') |
|
201 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'product']) |
|
202 | + ->setMethods(['getItems']) |
|
203 | 203 | ->getMock(); |
204 | 204 | |
205 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
206 | - ->will( $this->throwException( new \Exception() ) ); |
|
205 | + $object->expects($this->once())->method('getItems') |
|
206 | + ->will($this->throwException(new \Exception())); |
|
207 | 207 | |
208 | 208 | |
209 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
210 | - $result = json_decode( (string) $response->getBody(), true ); |
|
209 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
210 | + $result = json_decode((string) $response->getBody(), true); |
|
211 | 211 | |
212 | 212 | |
213 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
214 | - $this->assertArrayHasKey( 'errors', $result ); |
|
213 | + $this->assertEquals(500, $response->getStatusCode()); |
|
214 | + $this->assertArrayHasKey('errors', $result); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | \ No newline at end of file |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Standard( $this->context, $this->view, $templatePaths, '' ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Standard($this->context, $this->view, $templatePaths, ''); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testOptions() |
30 | 30 | { |
31 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
32 | - $result = json_decode( (string) $response->getBody(), true ); |
|
31 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
32 | + $result = json_decode((string) $response->getBody(), true); |
|
33 | 33 | |
34 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
35 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
36 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
34 | + $this->assertEquals(200, $response->getStatusCode()); |
|
35 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
36 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
37 | 37 | |
38 | - $this->assertEquals( null, $result['meta']['prefix'] ); |
|
39 | - $this->assertGreaterThan( 0, count( $result['meta']['resources'] ) ); |
|
40 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
38 | + $this->assertEquals(null, $result['meta']['prefix']); |
|
39 | + $this->assertGreaterThan(0, count($result['meta']['resources'])); |
|
40 | + $this->assertArrayNotHasKey('errors', $result); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | { |
46 | 46 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
47 | 47 | |
48 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Standard' ) |
|
49 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, ''] ) |
|
50 | - ->setMethods( ['getContext'] ) |
|
48 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Standard') |
|
49 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, '']) |
|
50 | + ->setMethods(['getContext']) |
|
51 | 51 | ->getMock(); |
52 | 52 | |
53 | - $object->expects( $this->once() )->method( 'getContext' ) |
|
54 | - ->will( $this->throwException( new \Exception() ) ); |
|
53 | + $object->expects($this->once())->method('getContext') |
|
54 | + ->will($this->throwException(new \Exception())); |
|
55 | 55 | |
56 | 56 | |
57 | - $response = $object->options( $this->view->request(), $this->view->response() ); |
|
58 | - $result = json_decode( (string) $response->getBody(), true ); |
|
57 | + $response = $object->options($this->view->request(), $this->view->response()); |
|
58 | + $result = json_decode((string) $response->getBody(), true); |
|
59 | 59 | |
60 | 60 | |
61 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
62 | - $this->assertArrayHasKey( 'errors', $result ); |
|
61 | + $this->assertEquals(500, $response->getStatusCode()); |
|
62 | + $this->assertArrayHasKey('errors', $result); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJapi::getContext(); |
17 | 17 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Client\JsonApi\Attribute\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
20 | - $this->assertInstanceOf( '\Aimeos\Client\JsonApi\Iface', $client ); |
|
19 | + $client = \Aimeos\Client\JsonApi\Attribute\Factory::createClient($context, $templatePaths, 'attribute'); |
|
20 | + $this->assertInstanceOf('\Aimeos\Client\JsonApi\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJapi::getContext(); |
27 | 27 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
28 | 28 | |
29 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
30 | - \Aimeos\Client\JsonApi\Attribute\Factory::createClient( $context, $templatePaths, '' ); |
|
29 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
30 | + \Aimeos\Client\JsonApi\Attribute\Factory::createClient($context, $templatePaths, ''); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJapi::getContext(); |
37 | 37 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
38 | 38 | |
39 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
40 | - \Aimeos\Client\JsonApi\Attribute\Factory::createClient( $context, $templatePaths, '%^' ); |
|
39 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
40 | + \Aimeos\Client\JsonApi\Attribute\Factory::createClient($context, $templatePaths, '%^'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $context = \TestHelperJapi::getContext(); |
47 | 47 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
50 | - \Aimeos\Client\JsonApi\Attribute\Factory::createClient( $context, $templatePaths, 'attribute', '%^' ); |
|
49 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
50 | + \Aimeos\Client\JsonApi\Attribute\Factory::createClient($context, $templatePaths, 'attribute', '%^'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Attribute\Standard( $this->context, $this->view, $templatePaths, 'attribute' ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Attribute\Standard($this->context, $this->view, $templatePaths, 'attribute'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testGetItem() |
30 | 30 | { |
31 | - $attrManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
32 | - $attrId = $attrManager->findItem( 'xs', [], 'product', 'size' )->getId(); |
|
31 | + $attrManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
32 | + $attrId = $attrManager->findItem('xs', [], 'product', 'size')->getId(); |
|
33 | 33 | |
34 | 34 | $params = array( |
35 | 35 | 'id' => $attrId, |
@@ -40,31 +40,31 @@ discard block |
||
40 | 40 | 'include' => 'media,price,text' |
41 | 41 | ); |
42 | 42 | |
43 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
44 | - $this->view->addHelper( 'param', $helper ); |
|
43 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
44 | + $this->view->addHelper('param', $helper); |
|
45 | 45 | |
46 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
47 | - $result = json_decode( (string) $response->getBody(), true ); |
|
46 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
47 | + $result = json_decode((string) $response->getBody(), true); |
|
48 | 48 | |
49 | 49 | |
50 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
51 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
52 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
50 | + $this->assertEquals(200, $response->getStatusCode()); |
|
51 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
52 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
53 | 53 | |
54 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
55 | - $this->assertEquals( 'attribute', $result['data']['type'] ); |
|
56 | - $this->assertEquals( 3, count( $result['data']['attributes']['text'] ) ); |
|
57 | - $this->assertEquals( 1, count( $result['data']['attributes']['price'] ) ); |
|
58 | - $this->assertEquals( 1, count( $result['data']['attributes']['media'] ) ); |
|
59 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
54 | + $this->assertEquals(1, $result['meta']['total']); |
|
55 | + $this->assertEquals('attribute', $result['data']['type']); |
|
56 | + $this->assertEquals(3, count($result['data']['attributes']['text'])); |
|
57 | + $this->assertEquals(1, count($result['data']['attributes']['price'])); |
|
58 | + $this->assertEquals(1, count($result['data']['attributes']['media'])); |
|
59 | + $this->assertEquals(0, count($result['included'])); |
|
60 | 60 | |
61 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
61 | + $this->assertArrayNotHasKey('errors', $result); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function testGetItems() |
66 | 66 | { |
67 | - $this->context->getConfig()->set( 'client/jsonapi/attribute/types', ['size', 'length', 'width'] ); |
|
67 | + $this->context->getConfig()->set('client/jsonapi/attribute/types', ['size', 'length', 'width']); |
|
68 | 68 | |
69 | 69 | $params = array( |
70 | 70 | 'fields' => array( |
@@ -73,29 +73,29 @@ discard block |
||
73 | 73 | 'include' => 'media,price,text', |
74 | 74 | 'sort' => 'attribute.position', |
75 | 75 | ); |
76 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
77 | - $this->view->addHelper( 'param', $helper ); |
|
78 | - |
|
79 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
80 | - $result = json_decode( (string) $response->getBody(), true ); |
|
81 | - |
|
82 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
83 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
84 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
85 | - |
|
86 | - $this->assertEquals( 17, $result['meta']['total'] ); |
|
87 | - $this->assertEquals( 17, count( $result['data'] ) ); |
|
88 | - $this->assertEquals( 'attribute', $result['data'][0]['type'] ); |
|
89 | - $this->assertEquals( 6, count( $result['data'][0]['attributes'] ) ); |
|
90 | - $this->assertEquals( 'size', $result['data'][0]['attributes']['attribute.type'] ); |
|
91 | - $this->assertEquals( 'xs', $result['data'][0]['attributes']['attribute.code'] ); |
|
92 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
93 | - |
|
94 | - foreach( $result['data'] as $entry ) { |
|
95 | - $this->assertContains( $entry['attributes']['attribute.type'], ['size', 'length', 'width'] ); |
|
76 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
77 | + $this->view->addHelper('param', $helper); |
|
78 | + |
|
79 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
80 | + $result = json_decode((string) $response->getBody(), true); |
|
81 | + |
|
82 | + $this->assertEquals(200, $response->getStatusCode()); |
|
83 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
84 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
85 | + |
|
86 | + $this->assertEquals(17, $result['meta']['total']); |
|
87 | + $this->assertEquals(17, count($result['data'])); |
|
88 | + $this->assertEquals('attribute', $result['data'][0]['type']); |
|
89 | + $this->assertEquals(6, count($result['data'][0]['attributes'])); |
|
90 | + $this->assertEquals('size', $result['data'][0]['attributes']['attribute.type']); |
|
91 | + $this->assertEquals('xs', $result['data'][0]['attributes']['attribute.code']); |
|
92 | + $this->assertEquals(0, count($result['included'])); |
|
93 | + |
|
94 | + foreach ($result['data'] as $entry) { |
|
95 | + $this->assertContains($entry['attributes']['attribute.type'], ['size', 'length', 'width']); |
|
96 | 96 | } |
97 | 97 | |
98 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
98 | + $this->assertArrayNotHasKey('errors', $result); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | { |
104 | 104 | $params = array( |
105 | 105 | 'filter' => array( |
106 | - '==' => array( 'attribute.type.code' => 'size' ), |
|
106 | + '==' => array('attribute.type.code' => 'size'), |
|
107 | 107 | ), |
108 | 108 | 'sort' => 'attribute.position', |
109 | 109 | ); |
110 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
111 | - $this->view->addHelper( 'param', $helper ); |
|
110 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
111 | + $this->view->addHelper('param', $helper); |
|
112 | 112 | |
113 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
114 | - $result = json_decode( (string) $response->getBody(), true ); |
|
113 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
114 | + $result = json_decode((string) $response->getBody(), true); |
|
115 | 115 | |
116 | 116 | |
117 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
118 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
119 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
117 | + $this->assertEquals(200, $response->getStatusCode()); |
|
118 | + $this->assertEquals(6, $result['meta']['total']); |
|
119 | + $this->assertArrayNotHasKey('errors', $result); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | { |
125 | 125 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
126 | 126 | |
127 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Attribute\Standard' ) |
|
128 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'attribute'] ) |
|
129 | - ->setMethods( ['getItems'] ) |
|
127 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Attribute\Standard') |
|
128 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'attribute']) |
|
129 | + ->setMethods(['getItems']) |
|
130 | 130 | ->getMock(); |
131 | 131 | |
132 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
133 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
132 | + $object->expects($this->once())->method('getItems') |
|
133 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
134 | 134 | |
135 | 135 | |
136 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
137 | - $result = json_decode( (string) $response->getBody(), true ); |
|
136 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
137 | + $result = json_decode((string) $response->getBody(), true); |
|
138 | 138 | |
139 | 139 | |
140 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
141 | - $this->assertArrayHasKey( 'errors', $result ); |
|
140 | + $this->assertEquals(404, $response->getStatusCode()); |
|
141 | + $this->assertArrayHasKey('errors', $result); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | { |
147 | 147 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
148 | 148 | |
149 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Attribute\Standard' ) |
|
150 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'attribute'] ) |
|
151 | - ->setMethods( ['getItems'] ) |
|
149 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Attribute\Standard') |
|
150 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'attribute']) |
|
151 | + ->setMethods(['getItems']) |
|
152 | 152 | ->getMock(); |
153 | 153 | |
154 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
155 | - ->will( $this->throwException( new \Exception() ) ); |
|
154 | + $object->expects($this->once())->method('getItems') |
|
155 | + ->will($this->throwException(new \Exception())); |
|
156 | 156 | |
157 | 157 | |
158 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
159 | - $result = json_decode( (string) $response->getBody(), true ); |
|
158 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
159 | + $result = json_decode((string) $response->getBody(), true); |
|
160 | 160 | |
161 | 161 | |
162 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
163 | - $this->assertArrayHasKey( 'errors', $result ); |
|
162 | + $this->assertEquals(500, $response->getStatusCode()); |
|
163 | + $this->assertArrayHasKey('errors', $result); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | \ No newline at end of file |
@@ -18,46 +18,46 @@ discard block |
||
18 | 18 | |
19 | 19 | $includepaths = $aimeos->getIncludePaths(); |
20 | 20 | $includepaths[] = get_include_path(); |
21 | - set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
21 | + set_include_path(implode(PATH_SEPARATOR, $includepaths)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | - public static function getContext( $site = 'unittest' ) |
|
25 | + public static function getContext($site = 'unittest') |
|
26 | 26 | { |
27 | - if( !isset( self::$context[$site] ) ) { |
|
28 | - self::$context[$site] = self::createContext( $site ); |
|
29 | - self::$context[$site]->setView( self::getView( self::$context[$site]->getConfig() ) ); |
|
27 | + if (!isset(self::$context[$site])) { |
|
28 | + self::$context[$site] = self::createContext($site); |
|
29 | + self::$context[$site]->setView(self::getView(self::$context[$site]->getConfig())); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | return clone self::$context[$site]; |
33 | 33 | } |
34 | 34 | |
35 | 35 | |
36 | - public static function getView( \Aimeos\MW\Config\Iface $config ) |
|
36 | + public static function getView(\Aimeos\MW\Config\Iface $config) |
|
37 | 37 | { |
38 | - $view = new \Aimeos\MW\View\Standard( self::getTemplatePaths() ); |
|
38 | + $view = new \Aimeos\MW\View\Standard(self::getTemplatePaths()); |
|
39 | 39 | |
40 | - $trans = new \Aimeos\MW\Translation\None( 'en' ); |
|
41 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
42 | - $view->addHelper( 'translate', $helper ); |
|
40 | + $trans = new \Aimeos\MW\Translation\None('en'); |
|
41 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
42 | + $view->addHelper('translate', $helper); |
|
43 | 43 | |
44 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'baseurl' ); |
|
45 | - $view->addHelper( 'url', $helper ); |
|
44 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'baseurl'); |
|
45 | + $view->addHelper('url', $helper); |
|
46 | 46 | |
47 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
48 | - $view->addHelper( 'number', $helper ); |
|
47 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
48 | + $view->addHelper('number', $helper); |
|
49 | 49 | |
50 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
51 | - $view->addHelper( 'date', $helper ); |
|
50 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
51 | + $view->addHelper('date', $helper); |
|
52 | 52 | |
53 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
54 | - $view->addHelper( 'config', $helper ); |
|
53 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
54 | + $view->addHelper('config', $helper); |
|
55 | 55 | |
56 | - $helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, new \Zend\Diactoros\ServerRequest() ); |
|
57 | - $view->addHelper( 'request', $helper ); |
|
56 | + $helper = new \Aimeos\MW\View\Helper\Request\Standard($view, new \Zend\Diactoros\ServerRequest()); |
|
57 | + $view->addHelper('request', $helper); |
|
58 | 58 | |
59 | - $helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, new \Zend\Diactoros\Response() ); |
|
60 | - $view->addHelper( 'response', $helper ); |
|
59 | + $helper = new \Aimeos\MW\View\Helper\Response\Standard($view, new \Zend\Diactoros\Response()); |
|
60 | + $view->addHelper('response', $helper); |
|
61 | 61 | |
62 | 62 | return $view; |
63 | 63 | } |
@@ -65,26 +65,26 @@ discard block |
||
65 | 65 | |
66 | 66 | public static function getTemplatePaths() |
67 | 67 | { |
68 | - return self::getAimeos()->getCustomPaths( 'client/jsonapi/templates' ); |
|
68 | + return self::getAimeos()->getCustomPaths('client/jsonapi/templates'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | private static function getAimeos() |
73 | 73 | { |
74 | - if( !isset( self::$aimeos ) ) |
|
74 | + if (!isset(self::$aimeos)) |
|
75 | 75 | { |
76 | 76 | require_once 'Bootstrap.php'; |
77 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
77 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
78 | 78 | |
79 | - $extdir = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ); |
|
80 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
79 | + $extdir = dirname(dirname(dirname(dirname(__DIR__)))); |
|
80 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$aimeos; |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - private static function createContext( $site ) |
|
87 | + private static function createContext($site) |
|
88 | 88 | { |
89 | 89 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
90 | 90 | $aimeos = self::getAimeos(); |
@@ -93,36 +93,36 @@ discard block |
||
93 | 93 | $paths = $aimeos->getConfigPaths(); |
94 | 94 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
95 | 95 | |
96 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $paths ); |
|
97 | - $ctx->setConfig( $conf ); |
|
96 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); |
|
97 | + $ctx->setConfig($conf); |
|
98 | 98 | |
99 | 99 | |
100 | - $dbm = new \Aimeos\MW\DB\Manager\DBAL( $conf ); |
|
101 | - $ctx->setDatabaseManager( $dbm ); |
|
100 | + $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf); |
|
101 | + $ctx->setDatabaseManager($dbm); |
|
102 | 102 | |
103 | 103 | |
104 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
105 | - $ctx->setLogger( $logger ); |
|
104 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
105 | + $ctx->setLogger($logger); |
|
106 | 106 | |
107 | 107 | |
108 | 108 | $cache = new \Aimeos\MW\Cache\None(); |
109 | - $ctx->setCache( $cache ); |
|
109 | + $ctx->setCache($cache); |
|
110 | 110 | |
111 | 111 | |
112 | - $i18n = new \Aimeos\MW\Translation\None( 'en' ); |
|
113 | - $ctx->setI18n( array( 'en' => $i18n ) ); |
|
112 | + $i18n = new \Aimeos\MW\Translation\None('en'); |
|
113 | + $ctx->setI18n(array('en' => $i18n)); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | $session = new \Aimeos\MW\Session\None(); |
117 | - $ctx->setSession( $session ); |
|
117 | + $ctx->setSession($session); |
|
118 | 118 | |
119 | 119 | |
120 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
121 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
122 | - $ctx->setLocale( $locale ); |
|
120 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
121 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
122 | + $ctx->setLocale($locale); |
|
123 | 123 | |
124 | 124 | |
125 | - $ctx->setEditor( 'ai-client-jsonapi:unittest' ); |
|
125 | + $ctx->setEditor('ai-client-jsonapi:unittest'); |
|
126 | 126 | |
127 | 127 | return $ctx; |
128 | 128 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | * Set error reporting to maximum |
5 | 5 | */ |
6 | 6 | error_reporting( -1 ); |
7 | -ini_set( 'display_errors', true ); |
|
7 | +ini_set('display_errors', true); |
|
8 | 8 | |
9 | -date_default_timezone_set( 'UTC' ); |
|
9 | +date_default_timezone_set('UTC'); |
|
10 | 10 | |
11 | 11 | /* |
12 | 12 | * Set locale settings to reasonable defaults |
13 | 13 | */ |
14 | -setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
15 | -setlocale( LC_CTYPE, 'en_US.UTF-8' ); |
|
16 | -setlocale( LC_NUMERIC, 'POSIX' ); |
|
17 | -setlocale( LC_TIME, 'POSIX' ); |
|
14 | +setlocale(LC_ALL, 'en_US.UTF-8'); |
|
15 | +setlocale(LC_CTYPE, 'en_US.UTF-8'); |
|
16 | +setlocale(LC_NUMERIC, 'POSIX'); |
|
17 | +setlocale(LC_TIME, 'POSIX'); |
|
18 | 18 | |
19 | 19 | |
20 | 20 | require_once 'TestHelperJapi.php'; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @see client/jsonapi/url/action |
23 | 23 | * @see client/jsonapi/url/config |
24 | 24 | */ |
25 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
25 | +$target = $this->config('client/jsonapi/url/target'); |
|
26 | 26 | |
27 | 27 | /** client/jsonapi/url/controller |
28 | 28 | * Name of the client whose action should be called |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @see client/jsonapi/url/action |
39 | 39 | * @see client/jsonapi/url/config |
40 | 40 | */ |
41 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
41 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
42 | 42 | |
43 | 43 | /** client/jsonapi/url/action |
44 | 44 | * Name of the action that should create the output |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @see client/jsonapi/url/controller |
55 | 55 | * @see client/jsonapi/url/config |
56 | 56 | */ |
57 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
57 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
58 | 58 | |
59 | 59 | /** client/jsonapi/url/config |
60 | 60 | * Associative list of configuration options used for generating the URL |
@@ -76,43 +76,43 @@ discard block |
||
76 | 76 | * @see client/jsonapi/url/controller |
77 | 77 | * @see client/jsonapi/url/action |
78 | 78 | */ |
79 | -$config = $this->config( 'client/jsonapi/url/config', array() ); |
|
79 | +$config = $this->config('client/jsonapi/url/config', array()); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | $view = $this; |
83 | 83 | $enc = $this->encoder(); |
84 | 84 | |
85 | 85 | |
86 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
87 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
86 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
87 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
88 | 88 | |
89 | 89 | |
90 | -$total = $this->get( 'total', 0 ); |
|
91 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
92 | -$limit = max( $this->param( 'page/limit', 48 ), 1 ); |
|
90 | +$total = $this->get('total', 0); |
|
91 | +$offset = max($this->param('page/offset', 0), 0); |
|
92 | +$limit = max($this->param('page/limit', 48), 1); |
|
93 | 93 | |
94 | -$first = ( $offset > 0 ? 0 : null ); |
|
95 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
96 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
97 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
94 | +$first = ($offset > 0 ? 0 : null); |
|
95 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
96 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
97 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
98 | 98 | |
99 | 99 | |
100 | -$map = $this->get( 'itemMap', array() ); |
|
101 | -$fields = $this->param( 'fields', array() ); |
|
100 | +$map = $this->get('itemMap', array()); |
|
101 | +$fields = $this->param('fields', array()); |
|
102 | 102 | |
103 | -foreach( (array) $fields as $resource => $list ) { |
|
104 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
103 | +foreach ((array) $fields as $resource => $list) { |
|
104 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | -$entryFcn = function( \Aimeos\MShop\Common\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config ) |
|
108 | +$entryFcn = function(\Aimeos\MShop\Common\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config) |
|
109 | 109 | { |
110 | 110 | $attributes = $item->toArray(); |
111 | 111 | $type = $item->getResourceType(); |
112 | - $params = array( 'resource' => $type, 'id' => $item->getId() ); |
|
112 | + $params = array('resource' => $type, 'id' => $item->getId()); |
|
113 | 113 | |
114 | - if( isset( $fields[$type] ) ) { |
|
115 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
114 | + if (isset($fields[$type])) { |
|
115 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $entry = array( |
@@ -120,36 +120,36 @@ discard block |
||
120 | 120 | 'type' => $item->getResourceType(), |
121 | 121 | 'links' => array( |
122 | 122 | 'self' => array( |
123 | - 'href' => $view->url( $target, $cntl, $action, $params, array(), $config ), |
|
124 | - 'allow' => array( 'GET' ), |
|
123 | + 'href' => $view->url($target, $cntl, $action, $params, array(), $config), |
|
124 | + 'allow' => array('GET'), |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | 'attributes' => $attributes, |
128 | 128 | ); |
129 | 129 | |
130 | - if( $item instanceof \Aimeos\MShop\Product\Item\Iface ) |
|
130 | + if ($item instanceof \Aimeos\MShop\Product\Item\Iface) |
|
131 | 131 | { |
132 | - foreach( $item->getPropertyItems() as $propertyItem ) { |
|
132 | + foreach ($item->getPropertyItems() as $propertyItem) { |
|
133 | 133 | $entry['attributes']['product/property'][] = $propertyItem->toArray(); |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface ) |
|
137 | + if ($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface) |
|
138 | 138 | { |
139 | - foreach( $item->getListItems() as $listItem ) |
|
139 | + foreach ($item->getListItems() as $listItem) |
|
140 | 140 | { |
141 | 141 | $domain = $listItem->getDomain(); |
142 | 142 | |
143 | - if( in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
144 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
143 | + if (in_array($domain, array('media', 'price', 'text'), true) |
|
144 | + && ($refItem = $listItem->getRefItem()) !== null |
|
145 | 145 | ) { |
146 | 146 | $entry['attributes'][$domain][] = $refItem->toArray() + $listItem->toArray(); |
147 | 147 | } |
148 | 148 | |
149 | - if( !in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
150 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
149 | + if (!in_array($domain, array('media', 'price', 'text'), true) |
|
150 | + && ($refItem = $listItem->getRefItem()) !== null |
|
151 | 151 | ) { |
152 | - $basic = array( 'id' => $refItem->getId(), 'type' => $domain ); |
|
152 | + $basic = array('id' => $refItem->getId(), 'type' => $domain); |
|
153 | 153 | $entry['relationships'][$domain]['data'][] = $basic + $listItem->toArray(); |
154 | 154 | } |
155 | 155 | } |
@@ -159,29 +159,29 @@ discard block |
||
159 | 159 | }; |
160 | 160 | |
161 | 161 | |
162 | -$refFcn = function( \Aimeos\MShop\Common\Item\Iface $item, $level ) use ( $map, $entryFcn, &$refFcn ) |
|
162 | +$refFcn = function(\Aimeos\MShop\Common\Item\Iface $item, $level) use ($map, $entryFcn, &$refFcn) |
|
163 | 163 | { |
164 | 164 | $list = array(); |
165 | 165 | |
166 | - if( !( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface ) || $level > 1 ) { |
|
166 | + if (!($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface) || $level > 1) { |
|
167 | 167 | return $list; |
168 | 168 | } |
169 | 169 | |
170 | - foreach( $item->getListItems() as $listItem ) |
|
170 | + foreach ($item->getListItems() as $listItem) |
|
171 | 171 | { |
172 | 172 | $domain = $listItem->getDomain(); |
173 | 173 | |
174 | - if( !in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
175 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
174 | + if (!in_array($domain, array('media', 'price', 'text'), true) |
|
175 | + && ($refItem = $listItem->getRefItem()) !== null |
|
176 | 176 | ) { |
177 | 177 | $id = $refItem->getId(); |
178 | 178 | |
179 | - if( isset( $map[$domain][$id] ) ) { |
|
179 | + if (isset($map[$domain][$id])) { |
|
180 | 180 | $refItem = $map[$domain][$id]; |
181 | 181 | } |
182 | 182 | |
183 | - $list[] = $entryFcn( $refItem ); |
|
184 | - $list = array_merge( $list, $refFcn( $refItem, ++$level ) ); |
|
183 | + $list[] = $entryFcn($refItem); |
|
184 | + $list = array_merge($list, $refFcn($refItem, ++$level)); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -197,51 +197,51 @@ discard block |
||
197 | 197 | }, |
198 | 198 | |
199 | 199 | "links": { |
200 | - <?php if( is_array( $this->get( 'items' ) ) ) : ?> |
|
201 | - <?php if( $first !== null ) : ?> |
|
202 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
200 | + <?php if (is_array($this->get('items'))) : ?> |
|
201 | + <?php if ($first !== null) : ?> |
|
202 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
203 | 203 | <?php endif; ?> |
204 | - <?php if( $prev !== null ) : ?> |
|
205 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
204 | + <?php if ($prev !== null) : ?> |
|
205 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
206 | 206 | <?php endif; ?> |
207 | - <?php if( $next !== null ) : ?> |
|
208 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
207 | + <?php if ($next !== null) : ?> |
|
208 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
209 | 209 | <?php endif; ?> |
210 | - <?php if( $last !== null ) : ?> |
|
211 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
210 | + <?php if ($last !== null) : ?> |
|
211 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
212 | 212 | <?php endif; ?> |
213 | 213 | <?php endif; ?> |
214 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
214 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
215 | 215 | }, |
216 | 216 | |
217 | - <?php if( isset( $this->errors ) ) : ?> |
|
217 | + <?php if (isset($this->errors)) : ?> |
|
218 | 218 | |
219 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
219 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
220 | 220 | |
221 | - <?php elseif( isset( $this->items ) ) : ?> |
|
221 | + <?php elseif (isset($this->items)) : ?> |
|
222 | 222 | |
223 | 223 | <?php |
224 | 224 | $data = $included = array(); |
225 | - $items = $this->get( 'items', array() ); |
|
225 | + $items = $this->get('items', array()); |
|
226 | 226 | |
227 | - if( is_array( $items ) ) |
|
227 | + if (is_array($items)) |
|
228 | 228 | { |
229 | - foreach( $items as $prodId => $productItem ) |
|
229 | + foreach ($items as $prodId => $productItem) |
|
230 | 230 | { |
231 | - $data[] = $entryFcn( $productItem ); |
|
232 | - $included = array_merge( $included, $refFcn( $productItem, 0 ) ); |
|
231 | + $data[] = $entryFcn($productItem); |
|
232 | + $included = array_merge($included, $refFcn($productItem, 0)); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | else |
236 | 236 | { |
237 | - $data = $entryFcn( $items ); |
|
238 | - $included = $refFcn( $items, 0 ); |
|
237 | + $data = $entryFcn($items); |
|
238 | + $included = $refFcn($items, 0); |
|
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | |
242 | - "data": <?php echo json_encode( $data ); ?>, |
|
242 | + "data": <?php echo json_encode($data); ?>, |
|
243 | 243 | |
244 | - "included": <?php echo json_encode( $included ); ?> |
|
244 | + "included": <?php echo json_encode($included); ?> |
|
245 | 245 | |
246 | 246 | <?php endif; ?> |
247 | 247 |
@@ -231,8 +231,7 @@ |
||
231 | 231 | $data[] = $entryFcn( $productItem ); |
232 | 232 | $included = array_merge( $included, $refFcn( $productItem, 0 ) ); |
233 | 233 | } |
234 | - } |
|
235 | - else |
|
234 | + } else |
|
236 | 235 | { |
237 | 236 | $data = $entryFcn( $items ); |
238 | 237 | $included = $refFcn( $items, 0 ); |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
4 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonapi' ); |
|
5 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
6 | -$config = $this->config( 'admin/jsonadm/url/config', [] ); |
|
3 | +$target = $this->config('admin/jsonadm/url/target'); |
|
4 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonapi'); |
|
5 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
6 | +$config = $this->config('admin/jsonadm/url/config', []); |
|
7 | 7 | |
8 | 8 | $resources = []; |
9 | -foreach( $this->get( 'resources', [] ) as $resource ) { |
|
10 | - $resources[$resource] = $this->url( $target, $cntl, $action, array( 'resource' => $resource, 'id' => '' ), [], $config ); |
|
9 | +foreach ($this->get('resources', []) as $resource) { |
|
10 | + $resources[$resource] = $this->url($target, $cntl, $action, array('resource' => $resource, 'id' => ''), [], $config); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | ?> |
14 | 14 | { |
15 | 15 | "meta": { |
16 | - "prefix": <?php echo json_encode( $this->get( 'prefix' ) ); ?>, |
|
17 | - "resources": <?php echo json_encode( $resources ); ?> |
|
16 | + "prefix": <?php echo json_encode($this->get('prefix')); ?>, |
|
17 | + "resources": <?php echo json_encode($resources); ?> |
|
18 | 18 | |
19 | 19 | } |
20 | 20 | |
21 | - <?php if( isset( $this->errors ) ) : ?> |
|
21 | + <?php if (isset($this->errors)) : ?> |
|
22 | 22 | |
23 | - , "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
23 | + , "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
24 | 24 | |
25 | 25 | <?php endif; ?> |
26 | 26 | } |
@@ -8,45 +8,45 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
12 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
13 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
14 | -$config = $this->config( 'client/jsonapi/url/config', array() ); |
|
11 | +$target = $this->config('client/jsonapi/url/target'); |
|
12 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
13 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
14 | +$config = $this->config('client/jsonapi/url/config', array()); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | $view = $this; |
18 | 18 | $enc = $this->encoder(); |
19 | 19 | |
20 | 20 | |
21 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
22 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
21 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
22 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
23 | 23 | |
24 | 24 | |
25 | -$total = $this->get( 'total', 0 ); |
|
26 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
27 | -$limit = max( $this->param( 'page/limit', 100 ), 1 ); |
|
25 | +$total = $this->get('total', 0); |
|
26 | +$offset = max($this->param('page/offset', 0), 0); |
|
27 | +$limit = max($this->param('page/limit', 100), 1); |
|
28 | 28 | |
29 | -$first = ( $offset > 0 ? 0 : null ); |
|
30 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
31 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
32 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
29 | +$first = ($offset > 0 ? 0 : null); |
|
30 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
31 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
32 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
33 | 33 | |
34 | 34 | |
35 | -$fields = $this->param( 'fields', array() ); |
|
35 | +$fields = $this->param('fields', array()); |
|
36 | 36 | |
37 | -foreach( (array) $fields as $resource => $list ) { |
|
38 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
37 | +foreach ((array) $fields as $resource => $list) { |
|
38 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | -$entryFcn = function( \Aimeos\MShop\Stock\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config ) |
|
42 | +$entryFcn = function(\Aimeos\MShop\Stock\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config) |
|
43 | 43 | { |
44 | 44 | $attributes = $item->toArray(); |
45 | 45 | $type = $item->getResourceType(); |
46 | - $params = array( 'resource' => $type, 'id' => $item->getId() ); |
|
46 | + $params = array('resource' => $type, 'id' => $item->getId()); |
|
47 | 47 | |
48 | - if( isset( $fields[$type] ) ) { |
|
49 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
48 | + if (isset($fields[$type])) { |
|
49 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $entry = array( |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | 'type' => $item->getResourceType(), |
55 | 55 | 'links' => array( |
56 | 56 | 'self' => array( |
57 | - 'href' => $view->url( $target, $cntl, $action, $params, array(), $config ), |
|
58 | - 'allow' => array( 'GET' ), |
|
57 | + 'href' => $view->url($target, $cntl, $action, $params, array(), $config), |
|
58 | + 'allow' => array('GET'), |
|
59 | 59 | ), |
60 | 60 | ), |
61 | 61 | 'attributes' => $attributes, |
@@ -73,46 +73,46 @@ discard block |
||
73 | 73 | }, |
74 | 74 | |
75 | 75 | "links": { |
76 | - <?php if( is_array( $this->get( 'items' ) ) ) : ?> |
|
77 | - <?php if( $first !== null ) : ?> |
|
78 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
76 | + <?php if (is_array($this->get('items'))) : ?> |
|
77 | + <?php if ($first !== null) : ?> |
|
78 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
79 | 79 | <?php endif; ?> |
80 | - <?php if( $prev !== null ) : ?> |
|
81 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
80 | + <?php if ($prev !== null) : ?> |
|
81 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
82 | 82 | <?php endif; ?> |
83 | - <?php if( $next !== null ) : ?> |
|
84 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
83 | + <?php if ($next !== null) : ?> |
|
84 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
85 | 85 | <?php endif; ?> |
86 | - <?php if( $last !== null ) : ?> |
|
87 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
86 | + <?php if ($last !== null) : ?> |
|
87 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
88 | 88 | <?php endif; ?> |
89 | 89 | <?php endif; ?> |
90 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
90 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
91 | 91 | }, |
92 | 92 | |
93 | - <?php if( isset( $this->errors ) ) : ?> |
|
93 | + <?php if (isset($this->errors)) : ?> |
|
94 | 94 | |
95 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
95 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
96 | 96 | |
97 | - <?php elseif( isset( $this->items ) ) : ?> |
|
97 | + <?php elseif (isset($this->items)) : ?> |
|
98 | 98 | |
99 | 99 | <?php |
100 | 100 | $data = $included = array(); |
101 | - $items = $this->get( 'items', array() ); |
|
101 | + $items = $this->get('items', array()); |
|
102 | 102 | |
103 | - if( is_array( $items ) ) |
|
103 | + if (is_array($items)) |
|
104 | 104 | { |
105 | - foreach( $items as $stockId => $stockItem ) { |
|
106 | - $data[] = $entryFcn( $stockItem ); |
|
105 | + foreach ($items as $stockId => $stockItem) { |
|
106 | + $data[] = $entryFcn($stockItem); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - $data = $entryFcn( $items ); |
|
111 | + $data = $entryFcn($items); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | |
115 | - "data": <?php echo json_encode( $data ); ?> |
|
115 | + "data": <?php echo json_encode($data); ?> |
|
116 | 116 | |
117 | 117 | <?php endif; ?> |
118 | 118 |
@@ -105,8 +105,7 @@ |
||
105 | 105 | foreach( $items as $stockId => $stockItem ) { |
106 | 106 | $data[] = $entryFcn( $stockItem ); |
107 | 107 | } |
108 | - } |
|
109 | - else |
|
108 | + } else |
|
110 | 109 | { |
111 | 110 | $data = $entryFcn( $items ); |
112 | 111 | } |