@@ -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\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,42 +34,42 @@ discard block |
||
34 | 34 | |
35 | 35 | public function testDelete() |
36 | 36 | { |
37 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ); |
|
37 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem'); |
|
38 | 38 | |
39 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
40 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
41 | - $this->view->addHelper( 'param', $helper ); |
|
39 | + $params = array('id' => $this->getProductItem()->getId()); |
|
40 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
41 | + $this->view->addHelper('param', $helper); |
|
42 | 42 | |
43 | 43 | $header = array(); |
44 | 44 | $status = 500; |
45 | 45 | |
46 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
46 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
47 | 47 | |
48 | - $this->assertEquals( 200, $status ); |
|
49 | - $this->assertEquals( 1, count( $header ) ); |
|
50 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
51 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
52 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
48 | + $this->assertEquals(200, $status); |
|
49 | + $this->assertEquals(1, count($header)); |
|
50 | + $this->assertEquals(1, $result['meta']['total']); |
|
51 | + $this->assertArrayNotHasKey('included', $result); |
|
52 | + $this->assertArrayNotHasKey('data', $result); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testDeleteBulk() |
58 | 58 | { |
59 | - $this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' ); |
|
59 | + $this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems'); |
|
60 | 60 | |
61 | 61 | $body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}'; |
62 | 62 | $header = array(); |
63 | 63 | $status = 500; |
64 | 64 | |
65 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
65 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
66 | 66 | |
67 | - $this->assertEquals( 200, $status ); |
|
68 | - $this->assertEquals( 1, count( $header ) ); |
|
69 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
70 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
71 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
72 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
67 | + $this->assertEquals(200, $status); |
|
68 | + $this->assertEquals(1, count($header)); |
|
69 | + $this->assertEquals(2, $result['meta']['total']); |
|
70 | + $this->assertArrayNotHasKey('included', $result); |
|
71 | + $this->assertArrayNotHasKey('data', $result); |
|
72 | + $this->assertArrayNotHasKey('errors', $result); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -79,71 +79,71 @@ discard block |
||
79 | 79 | $header = array(); |
80 | 80 | $status = 500; |
81 | 81 | |
82 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
82 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
83 | 83 | |
84 | - $this->assertEquals( 400, $status ); |
|
85 | - $this->assertEquals( 1, count( $header ) ); |
|
86 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
87 | - $this->assertArrayHasKey( 'errors', $result ); |
|
88 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
89 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
84 | + $this->assertEquals(400, $status); |
|
85 | + $this->assertEquals(1, count($header)); |
|
86 | + $this->assertEquals(0, $result['meta']['total']); |
|
87 | + $this->assertArrayHasKey('errors', $result); |
|
88 | + $this->assertArrayNotHasKey('included', $result); |
|
89 | + $this->assertArrayNotHasKey('data', $result); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testDeleteException() |
94 | 94 | { |
95 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
96 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
95 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
96 | + ->will($this->throwException(new \Exception('test exception'))); |
|
97 | 97 | |
98 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
99 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
100 | - $this->view->addHelper( 'param', $helper ); |
|
98 | + $params = array('id' => $this->getProductItem()->getId()); |
|
99 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
100 | + $this->view->addHelper('param', $helper); |
|
101 | 101 | |
102 | 102 | $header = array(); |
103 | 103 | $status = 500; |
104 | 104 | |
105 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
105 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
106 | 106 | |
107 | - $this->assertEquals( 500, $status ); |
|
108 | - $this->assertArrayHasKey( 'errors', $result ); |
|
107 | + $this->assertEquals(500, $status); |
|
108 | + $this->assertArrayHasKey('errors', $result); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | 112 | public function testDeleteMAdminException() |
113 | 113 | { |
114 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
115 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
114 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
115 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
116 | 116 | |
117 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
118 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
119 | - $this->view->addHelper( 'param', $helper ); |
|
117 | + $params = array('id' => $this->getProductItem()->getId()); |
|
118 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
119 | + $this->view->addHelper('param', $helper); |
|
120 | 120 | |
121 | 121 | $header = array(); |
122 | 122 | $status = 500; |
123 | 123 | |
124 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
124 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
125 | 125 | |
126 | - $this->assertEquals( 404, $status ); |
|
127 | - $this->assertArrayHasKey( 'errors', $result ); |
|
126 | + $this->assertEquals(404, $status); |
|
127 | + $this->assertArrayHasKey('errors', $result); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testDeleteMShopException() |
132 | 132 | { |
133 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
134 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
133 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
134 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
135 | 135 | |
136 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
137 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
138 | - $this->view->addHelper( 'param', $helper ); |
|
136 | + $params = array('id' => $this->getProductItem()->getId()); |
|
137 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
138 | + $this->view->addHelper('param', $helper); |
|
139 | 139 | |
140 | 140 | $header = array(); |
141 | 141 | $status = 500; |
142 | 142 | |
143 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
143 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
144 | 144 | |
145 | - $this->assertEquals( 404, $status ); |
|
146 | - $this->assertArrayHasKey( 'errors', $result ); |
|
145 | + $this->assertEquals(404, $status); |
|
146 | + $this->assertArrayHasKey('errors', $result); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | $header = array(); |
153 | 153 | $status = 500; |
154 | 154 | |
155 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
155 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
156 | 156 | |
157 | - $this->assertEquals( 200, $status ); |
|
158 | - $this->assertEquals( 1, count( $header ) ); |
|
159 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
160 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
161 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
162 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
163 | - $this->assertArrayHasKey( 'next', $result['links'] ); |
|
164 | - $this->assertArrayHasKey( 'last', $result['links'] ); |
|
165 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
166 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
157 | + $this->assertEquals(200, $status); |
|
158 | + $this->assertEquals(1, count($header)); |
|
159 | + $this->assertEquals(28, $result['meta']['total']); |
|
160 | + $this->assertEquals(25, count($result['data'])); |
|
161 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
162 | + $this->assertEquals(0, count($result['included'])); |
|
163 | + $this->assertArrayHasKey('next', $result['links']); |
|
164 | + $this->assertArrayHasKey('last', $result['links']); |
|
165 | + $this->assertArrayHasKey('self', $result['links']); |
|
166 | + $this->assertArrayNotHasKey('errors', $result); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | $status = 500; |
174 | 174 | |
175 | 175 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
176 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/stock/warehouse' ); |
|
176 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/stock/warehouse'); |
|
177 | 177 | |
178 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
178 | + $result = json_decode($object->get('', $header, $status), true); |
|
179 | 179 | |
180 | - $this->assertEquals( 200, $status ); |
|
181 | - $this->assertEquals( 1, count( $header ) ); |
|
182 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
183 | - $this->assertEquals( 6, count( $result['data'] ) ); |
|
184 | - $this->assertEquals( 'product/stock/warehouse', $result['data'][0]['type'] ); |
|
185 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
186 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
180 | + $this->assertEquals(200, $status); |
|
181 | + $this->assertEquals(1, count($header)); |
|
182 | + $this->assertEquals(6, $result['meta']['total']); |
|
183 | + $this->assertEquals(6, count($result['data'])); |
|
184 | + $this->assertEquals('product/stock/warehouse', $result['data'][0]['type']); |
|
185 | + $this->assertEquals(0, count($result['included'])); |
|
186 | + $this->assertArrayNotHasKey('errors', $result); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -193,74 +193,74 @@ discard block |
||
193 | 193 | $status = 500; |
194 | 194 | |
195 | 195 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
196 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' ); |
|
196 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid'); |
|
197 | 197 | |
198 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
198 | + $result = json_decode($object->get('', $header, $status), true); |
|
199 | 199 | |
200 | - $this->assertEquals( 404, $status ); |
|
201 | - $this->assertEquals( 1, count( $header ) ); |
|
202 | - $this->assertEquals( 1, count( $result['errors'] ) ); |
|
203 | - $this->assertArrayHasKey( 'title', $result['errors'][0] ); |
|
204 | - $this->assertArrayHasKey( 'detail', $result['errors'][0] ); |
|
205 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
206 | - $this->assertArrayNotHasKey( 'indluded', $result ); |
|
200 | + $this->assertEquals(404, $status); |
|
201 | + $this->assertEquals(1, count($header)); |
|
202 | + $this->assertEquals(1, count($result['errors'])); |
|
203 | + $this->assertArrayHasKey('title', $result['errors'][0]); |
|
204 | + $this->assertArrayHasKey('detail', $result['errors'][0]); |
|
205 | + $this->assertArrayNotHasKey('data', $result); |
|
206 | + $this->assertArrayNotHasKey('indluded', $result); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
210 | 210 | public function testGetException() |
211 | 211 | { |
212 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
213 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
212 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
213 | + ->will($this->throwException(new \Exception('test exception'))); |
|
214 | 214 | |
215 | - $params = array( 'id' => -1 ); |
|
216 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
217 | - $this->view->addHelper( 'param', $helper ); |
|
215 | + $params = array('id' => -1); |
|
216 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
217 | + $this->view->addHelper('param', $helper); |
|
218 | 218 | |
219 | 219 | $header = array(); |
220 | 220 | $status = 500; |
221 | 221 | |
222 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
222 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
223 | 223 | |
224 | - $this->assertEquals( 500, $status ); |
|
225 | - $this->assertArrayHasKey( 'errors', $result ); |
|
224 | + $this->assertEquals(500, $status); |
|
225 | + $this->assertArrayHasKey('errors', $result); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
229 | 229 | public function testGetMAdminException() |
230 | 230 | { |
231 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
232 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
231 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
232 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
233 | 233 | |
234 | - $params = array( 'id' => -1 ); |
|
235 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
236 | - $this->view->addHelper( 'param', $helper ); |
|
234 | + $params = array('id' => -1); |
|
235 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
236 | + $this->view->addHelper('param', $helper); |
|
237 | 237 | |
238 | 238 | $header = array(); |
239 | 239 | $status = 500; |
240 | 240 | |
241 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
241 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
242 | 242 | |
243 | - $this->assertEquals( 404, $status ); |
|
244 | - $this->assertArrayHasKey( 'errors', $result ); |
|
243 | + $this->assertEquals(404, $status); |
|
244 | + $this->assertArrayHasKey('errors', $result); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | 248 | public function testGetMShopException() |
249 | 249 | { |
250 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
251 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
250 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
251 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
252 | 252 | |
253 | - $params = array( 'id' => -1 ); |
|
254 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
255 | - $this->view->addHelper( 'param', $helper ); |
|
253 | + $params = array('id' => -1); |
|
254 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
255 | + $this->view->addHelper('param', $helper); |
|
256 | 256 | |
257 | 257 | $header = array(); |
258 | 258 | $status = 500; |
259 | 259 | |
260 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
260 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
261 | 261 | |
262 | - $this->assertEquals( 404, $status ); |
|
263 | - $this->assertArrayHasKey( 'errors', $result ); |
|
262 | + $this->assertEquals(404, $status); |
|
263 | + $this->assertArrayHasKey('errors', $result); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | { |
269 | 269 | $params = array( |
270 | 270 | 'filter' => array( |
271 | - '==' => array( 'product.type.code' => 'select' ) |
|
271 | + '==' => array('product.type.code' => 'select') |
|
272 | 272 | ) |
273 | 273 | ); |
274 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
275 | - $this->view->addHelper( 'param', $helper ); |
|
274 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
275 | + $this->view->addHelper('param', $helper); |
|
276 | 276 | |
277 | 277 | $header = array(); |
278 | 278 | $status = 500; |
279 | 279 | |
280 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
280 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
281 | 281 | |
282 | - $this->assertEquals( 200, $status ); |
|
283 | - $this->assertEquals( 1, count( $header ) ); |
|
284 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
285 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
286 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
287 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
288 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
282 | + $this->assertEquals(200, $status); |
|
283 | + $this->assertEquals(1, count($header)); |
|
284 | + $this->assertEquals(3, $result['meta']['total']); |
|
285 | + $this->assertEquals(3, count($result['data'])); |
|
286 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
287 | + $this->assertEquals(0, count($result['included'])); |
|
288 | + $this->assertArrayNotHasKey('errors', $result); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -294,26 +294,26 @@ discard block |
||
294 | 294 | $params = array( |
295 | 295 | 'filter' => array( |
296 | 296 | '&&' => array( |
297 | - array( '=~' => array( 'product.label' => 'Unittest: Test' ) ), |
|
298 | - array( '==' => array( 'product.type.code' => 'select' ) ), |
|
297 | + array('=~' => array('product.label' => 'Unittest: Test')), |
|
298 | + array('==' => array('product.type.code' => 'select')), |
|
299 | 299 | ) |
300 | 300 | ) |
301 | 301 | ); |
302 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
303 | - $this->view->addHelper( 'param', $helper ); |
|
302 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
303 | + $this->view->addHelper('param', $helper); |
|
304 | 304 | |
305 | 305 | $header = array(); |
306 | 306 | $status = 500; |
307 | 307 | |
308 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
308 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
309 | 309 | |
310 | - $this->assertEquals( 200, $status ); |
|
311 | - $this->assertEquals( 1, count( $header ) ); |
|
312 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
313 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
314 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
315 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
316 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
310 | + $this->assertEquals(200, $status); |
|
311 | + $this->assertEquals(1, count($header)); |
|
312 | + $this->assertEquals(2, $result['meta']['total']); |
|
313 | + $this->assertEquals(2, count($result['data'])); |
|
314 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
315 | + $this->assertEquals(0, count($result['included'])); |
|
316 | + $this->assertArrayNotHasKey('errors', $result); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | 'limit' => 25 |
326 | 326 | ) |
327 | 327 | ); |
328 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
329 | - $this->view->addHelper( 'param', $helper ); |
|
328 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
329 | + $this->view->addHelper('param', $helper); |
|
330 | 330 | |
331 | 331 | $header = array(); |
332 | 332 | $status = 500; |
333 | 333 | |
334 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
334 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
335 | 335 | |
336 | - $this->assertEquals( 200, $status ); |
|
337 | - $this->assertEquals( 1, count( $header ) ); |
|
338 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
339 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
340 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
341 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
342 | - $this->assertArrayHasKey( 'first', $result['links'] ); |
|
343 | - $this->assertArrayHasKey( 'prev', $result['links'] ); |
|
344 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
345 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
336 | + $this->assertEquals(200, $status); |
|
337 | + $this->assertEquals(1, count($header)); |
|
338 | + $this->assertEquals(28, $result['meta']['total']); |
|
339 | + $this->assertEquals(3, count($result['data'])); |
|
340 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
341 | + $this->assertEquals(0, count($result['included'])); |
|
342 | + $this->assertArrayHasKey('first', $result['links']); |
|
343 | + $this->assertArrayHasKey('prev', $result['links']); |
|
344 | + $this->assertArrayHasKey('self', $result['links']); |
|
345 | + $this->assertArrayNotHasKey('errors', $result); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | $params = array( |
352 | 352 | 'sort' => 'product.label,-product.code' |
353 | 353 | ); |
354 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
355 | - $this->view->addHelper( 'param', $helper ); |
|
354 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
355 | + $this->view->addHelper('param', $helper); |
|
356 | 356 | |
357 | 357 | $header = array(); |
358 | 358 | $status = 500; |
359 | 359 | |
360 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
360 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
361 | 361 | |
362 | - $this->assertEquals( 200, $status ); |
|
363 | - $this->assertEquals( 1, count( $header ) ); |
|
364 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
365 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
366 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
367 | - $this->assertEquals( 'ABCD', $result['data'][0]['attributes']['product.code'] ); |
|
368 | - $this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] ); |
|
369 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
370 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
362 | + $this->assertEquals(200, $status); |
|
363 | + $this->assertEquals(1, count($header)); |
|
364 | + $this->assertEquals(28, $result['meta']['total']); |
|
365 | + $this->assertEquals(25, count($result['data'])); |
|
366 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
367 | + $this->assertEquals('ABCD', $result['data'][0]['attributes']['product.code']); |
|
368 | + $this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']); |
|
369 | + $this->assertEquals(0, count($result['included'])); |
|
370 | + $this->assertArrayNotHasKey('errors', $result); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -380,88 +380,88 @@ discard block |
||
380 | 380 | 'sort' => 'product.id', |
381 | 381 | 'include' => 'product' |
382 | 382 | ); |
383 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
384 | - $this->view->addHelper( 'param', $helper ); |
|
383 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
384 | + $this->view->addHelper('param', $helper); |
|
385 | 385 | |
386 | 386 | $header = array(); |
387 | 387 | $status = 500; |
388 | 388 | |
389 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
389 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
390 | 390 | |
391 | - $this->assertEquals( 200, $status ); |
|
392 | - $this->assertEquals( 1, count( $header ) ); |
|
393 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
394 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
395 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
396 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
397 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
391 | + $this->assertEquals(200, $status); |
|
392 | + $this->assertEquals(1, count($header)); |
|
393 | + $this->assertEquals(28, $result['meta']['total']); |
|
394 | + $this->assertEquals(25, count($result['data'])); |
|
395 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
396 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
397 | + $this->assertArrayNotHasKey('errors', $result); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
401 | 401 | public function testPatch() |
402 | 402 | { |
403 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
403 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
404 | 404 | |
405 | 405 | $item = $productManagerStub->createItem(); |
406 | - $item->setLabel( 'test' ); |
|
407 | - $item->setId( '-1' ); |
|
406 | + $item->setLabel('test'); |
|
407 | + $item->setId('-1'); |
|
408 | 408 | |
409 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
410 | - $productManagerStub->expects( $this->exactly( 3 ) )->method( 'getItem' ) // 3x due to decorator |
|
411 | - ->will( $this->returnValue( $item ) ); |
|
409 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
410 | + $productManagerStub->expects($this->exactly(3))->method('getItem') // 3x due to decorator |
|
411 | + ->will($this->returnValue($item)); |
|
412 | 412 | |
413 | 413 | |
414 | - $params = array( 'id' => '-1' ); |
|
415 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
416 | - $this->view->addHelper( 'param', $helper ); |
|
414 | + $params = array('id' => '-1'); |
|
415 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
416 | + $this->view->addHelper('param', $helper); |
|
417 | 417 | |
418 | 418 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
419 | 419 | $header = array(); |
420 | 420 | $status = 500; |
421 | 421 | |
422 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
422 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
423 | 423 | |
424 | - $this->assertEquals( 200, $status ); |
|
425 | - $this->assertEquals( 1, count( $header ) ); |
|
426 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
427 | - $this->assertArrayHasKey( 'data', $result ); |
|
428 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
429 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
430 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
431 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
432 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
424 | + $this->assertEquals(200, $status); |
|
425 | + $this->assertEquals(1, count($header)); |
|
426 | + $this->assertEquals(1, $result['meta']['total']); |
|
427 | + $this->assertArrayHasKey('data', $result); |
|
428 | + $this->assertEquals('-1', $result['data']['id']); |
|
429 | + $this->assertEquals('product', $result['data']['type']); |
|
430 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
431 | + $this->assertArrayNotHasKey('included', $result); |
|
432 | + $this->assertArrayNotHasKey('errors', $result); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
436 | 436 | public function testPatchBulk() |
437 | 437 | { |
438 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
438 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
439 | 439 | |
440 | 440 | $item = $productManagerStub->createItem(); |
441 | - $item->setLabel( 'test' ); |
|
442 | - $item->setId( '-1' ); |
|
441 | + $item->setLabel('test'); |
|
442 | + $item->setId('-1'); |
|
443 | 443 | |
444 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
445 | - $productManagerStub->expects( $this->exactly( 6 ) )->method( 'getItem' ) // 6x due to decorator |
|
446 | - ->will( $this->returnValue( $item ) ); |
|
444 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
445 | + $productManagerStub->expects($this->exactly(6))->method('getItem') // 6x due to decorator |
|
446 | + ->will($this->returnValue($item)); |
|
447 | 447 | |
448 | 448 | |
449 | 449 | $body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
450 | 450 | $header = array(); |
451 | 451 | $status = 500; |
452 | 452 | |
453 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
453 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
454 | 454 | |
455 | - $this->assertEquals( 200, $status ); |
|
456 | - $this->assertEquals( 1, count( $header ) ); |
|
457 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
458 | - $this->assertArrayHasKey( 'data', $result ); |
|
459 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
460 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
461 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
462 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
463 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
464 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
455 | + $this->assertEquals(200, $status); |
|
456 | + $this->assertEquals(1, count($header)); |
|
457 | + $this->assertEquals(2, $result['meta']['total']); |
|
458 | + $this->assertArrayHasKey('data', $result); |
|
459 | + $this->assertEquals(2, count($result['data'])); |
|
460 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
461 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
462 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
463 | + $this->assertArrayNotHasKey('included', $result); |
|
464 | + $this->assertArrayNotHasKey('errors', $result); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | $header = array(); |
472 | 472 | $status = 500; |
473 | 473 | |
474 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
474 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
475 | 475 | |
476 | - $this->assertEquals( 400, $status ); |
|
477 | - $this->assertEquals( 1, count( $header ) ); |
|
478 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
479 | - $this->assertArrayHasKey( 'errors', $result ); |
|
480 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
481 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
476 | + $this->assertEquals(400, $status); |
|
477 | + $this->assertEquals(1, count($header)); |
|
478 | + $this->assertEquals(0, $result['meta']['total']); |
|
479 | + $this->assertArrayHasKey('errors', $result); |
|
480 | + $this->assertArrayNotHasKey('included', $result); |
|
481 | + $this->assertArrayNotHasKey('data', $result); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -488,139 +488,139 @@ discard block |
||
488 | 488 | $header = array(); |
489 | 489 | $status = 500; |
490 | 490 | |
491 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
491 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
492 | 492 | |
493 | - $this->assertEquals( 400, $status ); |
|
494 | - $this->assertEquals( 1, count( $header ) ); |
|
495 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
496 | - $this->assertArrayHasKey( 'errors', $result ); |
|
493 | + $this->assertEquals(400, $status); |
|
494 | + $this->assertEquals(1, count($header)); |
|
495 | + $this->assertEquals(0, $result['meta']['total']); |
|
496 | + $this->assertArrayHasKey('errors', $result); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
500 | 500 | public function testPatchException() |
501 | 501 | { |
502 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
503 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
502 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
503 | + ->will($this->throwException(new \Exception('test exception'))); |
|
504 | 504 | |
505 | 505 | $header = array(); |
506 | 506 | $status = 500; |
507 | 507 | |
508 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
508 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
509 | 509 | |
510 | - $this->assertEquals( 500, $status ); |
|
511 | - $this->assertArrayHasKey( 'errors', $result ); |
|
510 | + $this->assertEquals(500, $status); |
|
511 | + $this->assertArrayHasKey('errors', $result); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | 515 | public function testPatchMAdminException() |
516 | 516 | { |
517 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
518 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
517 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
518 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
519 | 519 | |
520 | 520 | $header = array(); |
521 | 521 | $status = 500; |
522 | 522 | |
523 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
523 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
524 | 524 | |
525 | - $this->assertEquals( 404, $status ); |
|
526 | - $this->assertArrayHasKey( 'errors', $result ); |
|
525 | + $this->assertEquals(404, $status); |
|
526 | + $this->assertArrayHasKey('errors', $result); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | |
530 | 530 | public function testPatchMShopException() |
531 | 531 | { |
532 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
533 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
532 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
533 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
534 | 534 | |
535 | 535 | $header = array(); |
536 | 536 | $status = 500; |
537 | 537 | |
538 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
538 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
539 | 539 | |
540 | - $this->assertEquals( 404, $status ); |
|
541 | - $this->assertArrayHasKey( 'errors', $result ); |
|
540 | + $this->assertEquals(404, $status); |
|
541 | + $this->assertArrayHasKey('errors', $result); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | |
545 | 545 | public function testPost() |
546 | 546 | { |
547 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
547 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
548 | 548 | |
549 | 549 | $item = $productManagerStub->createItem(); |
550 | - $item->setLabel( 'test' ); |
|
551 | - $item->setId( '-1' ); |
|
550 | + $item->setLabel('test'); |
|
551 | + $item->setId('-1'); |
|
552 | 552 | |
553 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
554 | - $productManagerStub->expects( $this->once() )->method( 'getItem' ) |
|
555 | - ->will( $this->returnValue( $item ) ); |
|
553 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
554 | + $productManagerStub->expects($this->once())->method('getItem') |
|
555 | + ->will($this->returnValue($item)); |
|
556 | 556 | |
557 | 557 | |
558 | 558 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
559 | 559 | $header = array(); |
560 | 560 | $status = 500; |
561 | 561 | |
562 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
562 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
563 | 563 | |
564 | - $this->assertEquals( 201, $status ); |
|
565 | - $this->assertEquals( 1, count( $header ) ); |
|
566 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
567 | - $this->assertArrayHasKey( 'data', $result ); |
|
568 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
569 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
570 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
571 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
572 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
564 | + $this->assertEquals(201, $status); |
|
565 | + $this->assertEquals(1, count($header)); |
|
566 | + $this->assertEquals(1, $result['meta']['total']); |
|
567 | + $this->assertArrayHasKey('data', $result); |
|
568 | + $this->assertEquals('-1', $result['data']['id']); |
|
569 | + $this->assertEquals('product', $result['data']['type']); |
|
570 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
571 | + $this->assertArrayNotHasKey('included', $result); |
|
572 | + $this->assertArrayNotHasKey('errors', $result); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | |
576 | 576 | public function testPostBulk() |
577 | 577 | { |
578 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
578 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
579 | 579 | |
580 | 580 | $item = $productManagerStub->createItem(); |
581 | - $item->setLabel( 'test' ); |
|
582 | - $item->setId( '-1' ); |
|
581 | + $item->setLabel('test'); |
|
582 | + $item->setId('-1'); |
|
583 | 583 | |
584 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
585 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
|
586 | - ->will( $this->returnValue( $item ) ); |
|
584 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
585 | + $productManagerStub->expects($this->exactly(2))->method('getItem') |
|
586 | + ->will($this->returnValue($item)); |
|
587 | 587 | |
588 | 588 | |
589 | 589 | $body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
590 | 590 | $header = array(); |
591 | 591 | $status = 500; |
592 | 592 | |
593 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
593 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
594 | 594 | |
595 | - $this->assertEquals( 201, $status ); |
|
596 | - $this->assertEquals( 1, count( $header ) ); |
|
597 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
598 | - $this->assertArrayHasKey( 'data', $result ); |
|
599 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
600 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
601 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
602 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
603 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
604 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
595 | + $this->assertEquals(201, $status); |
|
596 | + $this->assertEquals(1, count($header)); |
|
597 | + $this->assertEquals(2, $result['meta']['total']); |
|
598 | + $this->assertArrayHasKey('data', $result); |
|
599 | + $this->assertEquals(2, count($result['data'])); |
|
600 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
601 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
602 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
603 | + $this->assertArrayNotHasKey('included', $result); |
|
604 | + $this->assertArrayNotHasKey('errors', $result); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | |
608 | 608 | public function testPostRelationships() |
609 | 609 | { |
610 | - $productManagerStub = $this->getProductMock( array( 'getSubManager', 'getItem', 'saveItem' ) ); |
|
611 | - $productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) ); |
|
610 | + $productManagerStub = $this->getProductMock(array('getSubManager', 'getItem', 'saveItem')); |
|
611 | + $productManagerListsStub = $this->getProductListsMock(array('saveItem')); |
|
612 | 612 | |
613 | 613 | $item = $productManagerStub->createItem(); |
614 | - $item->setLabel( 'test' ); |
|
615 | - $item->setId( '-1' ); |
|
614 | + $item->setLabel('test'); |
|
615 | + $item->setId('-1'); |
|
616 | 616 | |
617 | - $productManagerStub->expects( $this->once() )->method( 'getItem' ) |
|
618 | - ->will( $this->returnValue( $item ) ); |
|
619 | - $productManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
620 | - ->will( $this->returnValue( $productManagerListsStub ) ); |
|
621 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
617 | + $productManagerStub->expects($this->once())->method('getItem') |
|
618 | + ->will($this->returnValue($item)); |
|
619 | + $productManagerStub->expects($this->once())->method('getSubManager') |
|
620 | + ->will($this->returnValue($productManagerListsStub)); |
|
621 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
622 | 622 | |
623 | - $productManagerListsStub->expects( $this->once() )->method( 'saveItem' ); |
|
623 | + $productManagerListsStub->expects($this->once())->method('saveItem'); |
|
624 | 624 | |
625 | 625 | $body = '{"data": {"type": "product", |
626 | 626 | "attributes": {"product.label": "test"}, |
@@ -631,17 +631,17 @@ discard block |
||
631 | 631 | $header = array(); |
632 | 632 | $status = 500; |
633 | 633 | |
634 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
634 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
635 | 635 | |
636 | - $this->assertEquals( 201, $status ); |
|
637 | - $this->assertEquals( 1, count( $header ) ); |
|
638 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
639 | - $this->assertArrayHasKey( 'data', $result ); |
|
640 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
641 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
642 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
643 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
644 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
636 | + $this->assertEquals(201, $status); |
|
637 | + $this->assertEquals(1, count($header)); |
|
638 | + $this->assertEquals(1, $result['meta']['total']); |
|
639 | + $this->assertArrayHasKey('data', $result); |
|
640 | + $this->assertEquals('-1', $result['data']['id']); |
|
641 | + $this->assertEquals('product', $result['data']['type']); |
|
642 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
643 | + $this->assertArrayNotHasKey('included', $result); |
|
644 | + $this->assertArrayNotHasKey('errors', $result); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | |
@@ -651,14 +651,14 @@ discard block |
||
651 | 651 | $header = array(); |
652 | 652 | $status = 500; |
653 | 653 | |
654 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
654 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
655 | 655 | |
656 | - $this->assertEquals( 400, $status ); |
|
657 | - $this->assertEquals( 1, count( $header ) ); |
|
658 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
659 | - $this->assertArrayHasKey( 'errors', $result ); |
|
660 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
661 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
656 | + $this->assertEquals(400, $status); |
|
657 | + $this->assertEquals(1, count($header)); |
|
658 | + $this->assertEquals(0, $result['meta']['total']); |
|
659 | + $this->assertArrayHasKey('errors', $result); |
|
660 | + $this->assertArrayNotHasKey('included', $result); |
|
661 | + $this->assertArrayNotHasKey('data', $result); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | |
@@ -668,57 +668,57 @@ discard block |
||
668 | 668 | $header = array(); |
669 | 669 | $status = 500; |
670 | 670 | |
671 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
671 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
672 | 672 | |
673 | - $this->assertEquals( 403, $status ); |
|
674 | - $this->assertEquals( 1, count( $header ) ); |
|
675 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
676 | - $this->assertArrayHasKey( 'errors', $result ); |
|
673 | + $this->assertEquals(403, $status); |
|
674 | + $this->assertEquals(1, count($header)); |
|
675 | + $this->assertEquals(0, $result['meta']['total']); |
|
676 | + $this->assertArrayHasKey('errors', $result); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
680 | 680 | public function testPostException() |
681 | 681 | { |
682 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
683 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
682 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
683 | + ->will($this->throwException(new \Exception('test exception'))); |
|
684 | 684 | |
685 | 685 | $header = array(); |
686 | 686 | $status = 500; |
687 | 687 | |
688 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
688 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
689 | 689 | |
690 | - $this->assertEquals( 500, $status ); |
|
691 | - $this->assertArrayHasKey( 'errors', $result ); |
|
690 | + $this->assertEquals(500, $status); |
|
691 | + $this->assertArrayHasKey('errors', $result); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
695 | 695 | public function testPostMAdminException() |
696 | 696 | { |
697 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
698 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
697 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
698 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
699 | 699 | |
700 | 700 | $header = array(); |
701 | 701 | $status = 500; |
702 | 702 | |
703 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
703 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
704 | 704 | |
705 | - $this->assertEquals( 404, $status ); |
|
706 | - $this->assertArrayHasKey( 'errors', $result ); |
|
705 | + $this->assertEquals(404, $status); |
|
706 | + $this->assertArrayHasKey('errors', $result); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
710 | 710 | public function testPostMShopException() |
711 | 711 | { |
712 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
713 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
712 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
713 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
714 | 714 | |
715 | 715 | $header = array(); |
716 | 716 | $status = 500; |
717 | 717 | |
718 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
718 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
719 | 719 | |
720 | - $this->assertEquals( 404, $status ); |
|
721 | - $this->assertArrayHasKey( 'errors', $result ); |
|
720 | + $this->assertEquals(404, $status); |
|
721 | + $this->assertArrayHasKey('errors', $result); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
@@ -728,11 +728,11 @@ discard block |
||
728 | 728 | $header = array(); |
729 | 729 | $status = 500; |
730 | 730 | |
731 | - $result = json_decode( $this->object->put( $body, $header, $status ), true ); |
|
731 | + $result = json_decode($this->object->put($body, $header, $status), true); |
|
732 | 732 | |
733 | - $this->assertEquals( 501, $status ); |
|
734 | - $this->assertEquals( 1, count( $header ) ); |
|
735 | - $this->assertArrayHasKey( 'errors', $result ); |
|
733 | + $this->assertEquals(501, $status); |
|
734 | + $this->assertEquals(1, count($header)); |
|
735 | + $this->assertArrayHasKey('errors', $result); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -741,102 +741,102 @@ discard block |
||
741 | 741 | $header = array(); |
742 | 742 | $status = 500; |
743 | 743 | |
744 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
744 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
745 | 745 | |
746 | - $this->assertEquals( 200, $status ); |
|
747 | - $this->assertEquals( 2, count( $header ) ); |
|
748 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
749 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
750 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
746 | + $this->assertEquals(200, $status); |
|
747 | + $this->assertEquals(2, count($header)); |
|
748 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
749 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
750 | + $this->assertArrayNotHasKey('errors', $result); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | |
754 | 754 | public function testOptionsException() |
755 | 755 | { |
756 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
757 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
756 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
757 | + ->will($this->throwException(new \Exception('test exception'))); |
|
758 | 758 | |
759 | 759 | $header = array(); |
760 | 760 | $status = 500; |
761 | 761 | |
762 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
762 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
763 | 763 | |
764 | - $this->assertEquals( 500, $status ); |
|
765 | - $this->assertArrayHasKey( 'errors', $result ); |
|
764 | + $this->assertEquals(500, $status); |
|
765 | + $this->assertArrayHasKey('errors', $result); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | |
769 | 769 | public function testOptionsMAdminException() |
770 | 770 | { |
771 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
772 | - ->will( $this->throwException( new \Aimeos\MAdmin\Exception( 'test exception' ) ) ); |
|
771 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
772 | + ->will($this->throwException(new \Aimeos\MAdmin\Exception('test exception'))); |
|
773 | 773 | |
774 | 774 | $header = array(); |
775 | 775 | $status = 500; |
776 | 776 | |
777 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
777 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
778 | 778 | |
779 | - $this->assertEquals( 404, $status ); |
|
780 | - $this->assertArrayHasKey( 'errors', $result ); |
|
779 | + $this->assertEquals(404, $status); |
|
780 | + $this->assertArrayHasKey('errors', $result); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | |
784 | 784 | public function testOptionsMShopException() |
785 | 785 | { |
786 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
787 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
786 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
787 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
788 | 788 | |
789 | 789 | $header = array(); |
790 | 790 | $status = 500; |
791 | 791 | |
792 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
792 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
793 | 793 | |
794 | - $this->assertEquals( 404, $status ); |
|
795 | - $this->assertArrayHasKey( 'errors', $result ); |
|
794 | + $this->assertEquals(404, $status); |
|
795 | + $this->assertArrayHasKey('errors', $result); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | |
799 | - protected function getProductMock( array $methods ) |
|
799 | + protected function getProductMock(array $methods) |
|
800 | 800 | { |
801 | 801 | $name = 'ClientJsonAdmStandard'; |
802 | - $this->context->getConfig()->set( 'mshop/product/manager/name', $name ); |
|
802 | + $this->context->getConfig()->set('mshop/product/manager/name', $name); |
|
803 | 803 | |
804 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' ) |
|
805 | - ->setConstructorArgs( array( $this->context ) ) |
|
806 | - ->setMethods( $methods ) |
|
804 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard') |
|
805 | + ->setConstructorArgs(array($this->context)) |
|
806 | + ->setMethods($methods) |
|
807 | 807 | ->getMock(); |
808 | 808 | |
809 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub ); |
|
809 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub); |
|
810 | 810 | |
811 | 811 | return $stub; |
812 | 812 | } |
813 | 813 | |
814 | 814 | |
815 | - protected function getProductListsMock( array $methods ) |
|
815 | + protected function getProductListsMock(array $methods) |
|
816 | 816 | { |
817 | 817 | $name = 'ClientJsonAdmStandard'; |
818 | - $this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name ); |
|
818 | + $this->context->getConfig()->set('mshop/product/manager/lists/name', $name); |
|
819 | 819 | |
820 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
821 | - ->setConstructorArgs( array( $this->context ) ) |
|
822 | - ->setMethods( $methods ) |
|
820 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
821 | + ->setConstructorArgs(array($this->context)) |
|
822 | + ->setMethods($methods) |
|
823 | 823 | ->getMock(); |
824 | 824 | |
825 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub ); |
|
825 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub); |
|
826 | 826 | |
827 | 827 | return $stub; |
828 | 828 | } |
829 | 829 | |
830 | 830 | |
831 | - protected function getProductItem( $code = 'CNC' ) |
|
831 | + protected function getProductItem($code = 'CNC') |
|
832 | 832 | { |
833 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
833 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
834 | 834 | $search = $manager->createSearch(); |
835 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
836 | - $items = $manager->searchItems( $search ); |
|
835 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
836 | + $items = $manager->searchItems($search); |
|
837 | 837 | |
838 | - if( ( $item = reset( $items ) ) === false ) { |
|
839 | - throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) ); |
|
838 | + if (($item = reset($items)) === false) { |
|
839 | + throw new \Exception(sprintf('No product item with code "%1$s" found', $code)); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | return $item; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
37 | 37 | { |
38 | 38 | $this->view = $view; |
39 | 39 | $this->context = $context; |
@@ -50,48 +50,48 @@ discard block |
||
50 | 50 | * @param integer &$status Variable which contains the HTTP status afterwards |
51 | 51 | * @return string Content for response body |
52 | 52 | */ |
53 | - public function delete( $body, array &$header, &$status ) |
|
53 | + public function delete($body, array &$header, &$status) |
|
54 | 54 | { |
55 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
55 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
56 | 56 | $context = $this->getContext(); |
57 | 57 | $view = $this->getView(); |
58 | 58 | |
59 | 59 | try |
60 | 60 | { |
61 | - $view = $this->deleteItems( $view, $body ); |
|
61 | + $view = $this->deleteItems($view, $body); |
|
62 | 62 | $status = 200; |
63 | 63 | } |
64 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
64 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
65 | 65 | { |
66 | 66 | $status = $e->getCode(); |
67 | - $view->errors = array( array( |
|
68 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
67 | + $view->errors = array(array( |
|
68 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
69 | 69 | 'detail' => $e->getTraceAsString(), |
70 | - ) ); |
|
70 | + )); |
|
71 | 71 | } |
72 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
72 | + catch (\Aimeos\MAdmin\Exception $e) |
|
73 | 73 | { |
74 | 74 | $status = 404; |
75 | - $view->errors = array( array( |
|
76 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
75 | + $view->errors = array(array( |
|
76 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
77 | 77 | 'detail' => $e->getTraceAsString(), |
78 | - ) ); |
|
78 | + )); |
|
79 | 79 | } |
80 | - catch( \Aimeos\MShop\Exception $e ) |
|
80 | + catch (\Aimeos\MShop\Exception $e) |
|
81 | 81 | { |
82 | 82 | $status = 404; |
83 | - $view->errors = array( array( |
|
84 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
83 | + $view->errors = array(array( |
|
84 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
85 | 85 | 'detail' => $e->getTraceAsString(), |
86 | - ) ); |
|
86 | + )); |
|
87 | 87 | } |
88 | - catch( \Exception $e ) |
|
88 | + catch (\Exception $e) |
|
89 | 89 | { |
90 | 90 | $status = 500; |
91 | - $view->errors = array( array( |
|
91 | + $view->errors = array(array( |
|
92 | 92 | 'title' => $e->getMessage(), |
93 | 93 | 'detail' => $e->getTraceAsString(), |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** admin/jsonadm/standard/template-delete |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
122 | 122 | $default = 'delete-default.php'; |
123 | 123 | |
124 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
124 | + return $view->render($view->config($tplconf, $default)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -133,39 +133,39 @@ discard block |
||
133 | 133 | * @param integer &$status Variable which contains the HTTP status afterwards |
134 | 134 | * @return string Content for response body |
135 | 135 | */ |
136 | - public function get( $body, array &$header, &$status ) |
|
136 | + public function get($body, array &$header, &$status) |
|
137 | 137 | { |
138 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
138 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
139 | 139 | $view = $this->getView(); |
140 | 140 | |
141 | 141 | try |
142 | 142 | { |
143 | - $view = $this->getItem( $view ); |
|
143 | + $view = $this->getItem($view); |
|
144 | 144 | $status = 200; |
145 | 145 | } |
146 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
146 | + catch (\Aimeos\MAdmin\Exception $e) |
|
147 | 147 | { |
148 | 148 | $status = 404; |
149 | - $view->errors = array( array( |
|
150 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
149 | + $view->errors = array(array( |
|
150 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
151 | 151 | 'detail' => $e->getTraceAsString(), |
152 | - ) ); |
|
152 | + )); |
|
153 | 153 | } |
154 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + catch (\Aimeos\MShop\Exception $e) |
|
155 | 155 | { |
156 | 156 | $status = 404; |
157 | - $view->errors = array( array( |
|
158 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
157 | + $view->errors = array(array( |
|
158 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
159 | 159 | 'detail' => $e->getTraceAsString(), |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | - catch( \Exception $e ) |
|
162 | + catch (\Exception $e) |
|
163 | 163 | { |
164 | 164 | $status = 500; |
165 | - $view->errors = array( array( |
|
165 | + $view->errors = array(array( |
|
166 | 166 | 'title' => $e->getMessage(), |
167 | 167 | 'detail' => $e->getTraceAsString(), |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** admin/jsonadm/standard/template-get |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $tplconf = 'admin/jsonadm/standard/template-get'; |
196 | 196 | $default = 'get-default.php'; |
197 | 197 | |
198 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
198 | + return $view->render($view->config($tplconf, $default)); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -207,48 +207,48 @@ discard block |
||
207 | 207 | * @param integer &$status Variable which contains the HTTP status afterwards |
208 | 208 | * @return string Content for response body |
209 | 209 | */ |
210 | - public function patch( $body, array &$header, &$status ) |
|
210 | + public function patch($body, array &$header, &$status) |
|
211 | 211 | { |
212 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
212 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
213 | 213 | $context = $this->getContext(); |
214 | 214 | $view = $this->getView(); |
215 | 215 | |
216 | 216 | try |
217 | 217 | { |
218 | - $view = $this->patchItems( $view, $body, $header ); |
|
218 | + $view = $this->patchItems($view, $body, $header); |
|
219 | 219 | $status = 200; |
220 | 220 | } |
221 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
221 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
222 | 222 | { |
223 | 223 | $status = $e->getCode(); |
224 | - $view->errors = array( array( |
|
225 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
224 | + $view->errors = array(array( |
|
225 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
226 | 226 | 'detail' => $e->getTraceAsString(), |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | } |
229 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
229 | + catch (\Aimeos\MAdmin\Exception $e) |
|
230 | 230 | { |
231 | 231 | $status = 404; |
232 | - $view->errors = array( array( |
|
233 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
232 | + $view->errors = array(array( |
|
233 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
234 | 234 | 'detail' => $e->getTraceAsString(), |
235 | - ) ); |
|
235 | + )); |
|
236 | 236 | } |
237 | - catch( \Aimeos\MShop\Exception $e ) |
|
237 | + catch (\Aimeos\MShop\Exception $e) |
|
238 | 238 | { |
239 | 239 | $status = 404; |
240 | - $view->errors = array( array( |
|
241 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
240 | + $view->errors = array(array( |
|
241 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
242 | 242 | 'detail' => $e->getTraceAsString(), |
243 | - ) ); |
|
243 | + )); |
|
244 | 244 | } |
245 | - catch( \Exception $e ) |
|
245 | + catch (\Exception $e) |
|
246 | 246 | { |
247 | 247 | $status = 500; |
248 | - $view->errors = array( array( |
|
248 | + $view->errors = array(array( |
|
249 | 249 | 'title' => $e->getMessage(), |
250 | 250 | 'detail' => $e->getTraceAsString(), |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** admin/jsonadm/standard/template-patch |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
279 | 279 | $default = 'patch-default.php'; |
280 | 280 | |
281 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
281 | + return $view->render($view->config($tplconf, $default)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -290,48 +290,48 @@ discard block |
||
290 | 290 | * @param integer &$status Variable which contains the HTTP status afterwards |
291 | 291 | * @return string Content for response body |
292 | 292 | */ |
293 | - public function post( $body, array &$header, &$status ) |
|
293 | + public function post($body, array &$header, &$status) |
|
294 | 294 | { |
295 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
295 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
296 | 296 | $context = $this->getContext(); |
297 | 297 | $view = $this->getView(); |
298 | 298 | |
299 | 299 | try |
300 | 300 | { |
301 | - $view = $this->postItems( $view, $body, $header ); |
|
301 | + $view = $this->postItems($view, $body, $header); |
|
302 | 302 | $status = 201; |
303 | 303 | } |
304 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
304 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
305 | 305 | { |
306 | 306 | $status = $e->getCode(); |
307 | - $view->errors = array( array( |
|
308 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
307 | + $view->errors = array(array( |
|
308 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
309 | 309 | 'detail' => $e->getTraceAsString(), |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | } |
312 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
312 | + catch (\Aimeos\MAdmin\Exception $e) |
|
313 | 313 | { |
314 | 314 | $status = 404; |
315 | - $view->errors = array( array( |
|
316 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
315 | + $view->errors = array(array( |
|
316 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
317 | 317 | 'detail' => $e->getTraceAsString(), |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | } |
320 | - catch( \Aimeos\MShop\Exception $e ) |
|
320 | + catch (\Aimeos\MShop\Exception $e) |
|
321 | 321 | { |
322 | 322 | $status = 404; |
323 | - $view->errors = array( array( |
|
324 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
323 | + $view->errors = array(array( |
|
324 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
325 | 325 | 'detail' => $e->getTraceAsString(), |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | } |
328 | - catch( \Exception $e ) |
|
328 | + catch (\Exception $e) |
|
329 | 329 | { |
330 | 330 | $status = 500; |
331 | - $view->errors = array( array( |
|
331 | + $view->errors = array(array( |
|
332 | 332 | 'title' => $e->getMessage(), |
333 | 333 | 'detail' => $e->getTraceAsString(), |
334 | - ) ); |
|
334 | + )); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** admin/jsonadm/standard/template-post |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $tplconf = 'admin/jsonadm/standard/template-post'; |
362 | 362 | $default = 'post-default.php'; |
363 | 363 | |
364 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
364 | + return $view->render($view->config($tplconf, $default)); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | * @param integer &$status Variable which contains the HTTP status afterwards |
374 | 374 | * @return string Content for response body |
375 | 375 | */ |
376 | - public function put( $body, array &$header, &$status ) |
|
376 | + public function put($body, array &$header, &$status) |
|
377 | 377 | { |
378 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
378 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
379 | 379 | $status = 501; |
380 | 380 | |
381 | 381 | $context = $this->getContext(); |
382 | 382 | $view = $this->getView(); |
383 | 383 | |
384 | - $view->errors = array( array( |
|
385 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
386 | - ) ); |
|
384 | + $view->errors = array(array( |
|
385 | + 'title' => $context->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
386 | + )); |
|
387 | 387 | |
388 | 388 | /** admin/jsonadm/standard/template-put |
389 | 389 | * Relative path to the JSON API template for PUT requests |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $tplconf = 'admin/jsonadm/standard/template-put'; |
413 | 413 | $default = 'put-default.php'; |
414 | 414 | |
415 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
415 | + return $view->render($view->config($tplconf, $default)); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param integer &$status Variable which contains the HTTP status afterwards |
425 | 425 | * @return string Content for response body |
426 | 426 | */ |
427 | - public function options( $body, array &$header, &$status ) |
|
427 | + public function options($body, array &$header, &$status) |
|
428 | 428 | { |
429 | 429 | $context = $this->getContext(); |
430 | 430 | $view = $this->getView(); |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | { |
434 | 434 | $resources = $attributes = array(); |
435 | 435 | |
436 | - foreach( $this->getDomains( $view ) as $domain ) |
|
436 | + foreach ($this->getDomains($view) as $domain) |
|
437 | 437 | { |
438 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
439 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
440 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
438 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
439 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
440 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $view->resources = $resources; |
@@ -449,29 +449,29 @@ discard block |
||
449 | 449 | ); |
450 | 450 | $status = 200; |
451 | 451 | } |
452 | - catch( \Aimeos\MAdmin\Exception $e ) |
|
452 | + catch (\Aimeos\MAdmin\Exception $e) |
|
453 | 453 | { |
454 | 454 | $status = 404; |
455 | - $view->errors = array( array( |
|
456 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
455 | + $view->errors = array(array( |
|
456 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
457 | 457 | 'detail' => $e->getTraceAsString(), |
458 | - ) ); |
|
458 | + )); |
|
459 | 459 | } |
460 | - catch( \Aimeos\MShop\Exception $e ) |
|
460 | + catch (\Aimeos\MShop\Exception $e) |
|
461 | 461 | { |
462 | 462 | $status = 404; |
463 | - $view->errors = array( array( |
|
464 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
463 | + $view->errors = array(array( |
|
464 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
465 | 465 | 'detail' => $e->getTraceAsString(), |
466 | - ) ); |
|
466 | + )); |
|
467 | 467 | } |
468 | - catch( \Exception $e ) |
|
468 | + catch (\Exception $e) |
|
469 | 469 | { |
470 | 470 | $status = 500; |
471 | - $view->errors = array( array( |
|
471 | + $view->errors = array(array( |
|
472 | 472 | 'title' => $e->getMessage(), |
473 | 473 | 'detail' => $e->getTraceAsString(), |
474 | - ) ); |
|
474 | + )); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** admin/jsonadm/standard/template-options |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $tplconf = 'admin/jsonadm/standard/template-options'; |
502 | 502 | $default = 'options-default.php'; |
503 | 503 | |
504 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
504 | + return $view->render($view->config($tplconf, $default)); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -513,23 +513,23 @@ discard block |
||
513 | 513 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
514 | 514 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
515 | 515 | */ |
516 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
516 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
517 | 517 | { |
518 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
518 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
519 | 519 | |
520 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
520 | + if (($id = $view->param('id')) == null) |
|
521 | 521 | { |
522 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
523 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
522 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
523 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
524 | 524 | } |
525 | 525 | |
526 | - $ids = $this->getIds( $request ); |
|
527 | - $manager->deleteItems( $ids ); |
|
528 | - $view->total = count( $ids ); |
|
526 | + $ids = $this->getIds($request); |
|
527 | + $manager->deleteItems($ids); |
|
528 | + $view->total = count($ids); |
|
529 | 529 | } |
530 | 530 | else |
531 | 531 | { |
532 | - $manager->deleteItem( $id ); |
|
532 | + $manager->deleteItem($id); |
|
533 | 533 | $view->total = 1; |
534 | 534 | } |
535 | 535 | |
@@ -543,27 +543,27 @@ discard block |
||
543 | 543 | * @param \Aimeos\MW\View\Iface $view View instance |
544 | 544 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
545 | 545 | */ |
546 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
546 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
547 | 547 | { |
548 | 548 | $total = 1; |
549 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
550 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
549 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
550 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
551 | 551 | |
552 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
552 | + if (($id = $view->param('id')) == null) |
|
553 | 553 | { |
554 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
555 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
556 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
557 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
554 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
555 | + $view->data = $manager->searchItems($search, array(), $total); |
|
556 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
557 | + $view->listItems = $this->getListItems($view->data, $include); |
|
558 | 558 | } |
559 | 559 | else |
560 | 560 | { |
561 | - $view->data = $manager->getItem( $id, array() ); |
|
562 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
563 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
561 | + $view->data = $manager->getItem($id, array()); |
|
562 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
563 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
564 | 564 | } |
565 | 565 | |
566 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
566 | + $view->refItems = $this->getRefItems($view->listItems); |
|
567 | 567 | |
568 | 568 | $view->total = $total; |
569 | 569 | |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | * @param array $params List of criteria data with condition, sorting and paging |
589 | 589 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
590 | 590 | */ |
591 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
591 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
592 | 592 | { |
593 | - $this->initCriteriaConditions( $criteria, $params ); |
|
594 | - $this->initCriteriaSortations( $criteria, $params ); |
|
595 | - $this->initCriteriaSlice( $criteria, $params ); |
|
593 | + $this->initCriteriaConditions($criteria, $params); |
|
594 | + $this->initCriteriaSortations($criteria, $params); |
|
595 | + $this->initCriteriaSlice($criteria, $params); |
|
596 | 596 | |
597 | 597 | return $criteria; |
598 | 598 | } |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
605 | 605 | * @param array $params List of criteria data with condition, sorting and paging |
606 | 606 | */ |
607 | - private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
607 | + private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
608 | 608 | { |
609 | - if( isset( $params['filter'] ) && is_array( $params['filter'] ) ) |
|
609 | + if (isset($params['filter']) && is_array($params['filter'])) |
|
610 | 610 | { |
611 | 611 | $existing = $criteria->getConditions(); |
612 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
612 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
613 | 613 | |
614 | - $expr = array( $criteria->getConditions(), $existing ); |
|
615 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
614 | + $expr = array($criteria->getConditions(), $existing); |
|
615 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
624 | 624 | * @param array $params List of criteria data with condition, sorting and paging |
625 | 625 | */ |
626 | - private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
626 | + private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
627 | 627 | { |
628 | - $start = ( isset( $params['page']['offset'] ) ? $params['page']['offset'] : 0 ); |
|
629 | - $size = ( isset( $params['page']['limit'] ) ? $params['page']['limit'] : 25 ); |
|
628 | + $start = (isset($params['page']['offset']) ? $params['page']['offset'] : 0); |
|
629 | + $size = (isset($params['page']['limit']) ? $params['page']['limit'] : 25); |
|
630 | 630 | |
631 | - $criteria->setSlice( $start, $size ); |
|
631 | + $criteria->setSlice($start, $size); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
@@ -638,24 +638,24 @@ discard block |
||
638 | 638 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
639 | 639 | * @param array $params List of criteria data with condition, sorting and paging |
640 | 640 | */ |
641 | - private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
641 | + private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
642 | 642 | { |
643 | - if( !isset( $params['sort'] ) ) { |
|
643 | + if (!isset($params['sort'])) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
647 | 647 | $sortation = array(); |
648 | 648 | |
649 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
649 | + foreach (explode(',', $params['sort']) as $sort) |
|
650 | 650 | { |
651 | - if( $sort[0] === '-' ) { |
|
652 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
651 | + if ($sort[0] === '-') { |
|
652 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
653 | 653 | } else { |
654 | - $sortation[] = $criteria->sort( '+', $sort ); break; |
|
654 | + $sortation[] = $criteria->sort('+', $sort); break; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | - $criteria->setSortations( $sortation ); |
|
658 | + $criteria->setSortations($sortation); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -665,9 +665,9 @@ discard block |
||
665 | 665 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
666 | 666 | * @return array List of domain names |
667 | 667 | */ |
668 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
668 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
669 | 669 | { |
670 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
670 | + if (($domains = $view->param('resource')) == '') |
|
671 | 671 | { |
672 | 672 | /** admin/jsonadm/domains |
673 | 673 | * A list of domain names whose clients are available for the JSON API |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
690 | 690 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
691 | 691 | ); |
692 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
692 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | return (array) $domains; |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @param array $include List of resource types that should be fetched |
704 | 704 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
705 | 705 | */ |
706 | - protected function getChildItems( array $items, array $include ) |
|
706 | + protected function getChildItems(array $items, array $include) |
|
707 | 707 | { |
708 | 708 | return array(); |
709 | 709 | } |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param array $include List of resource types that should be fetched |
717 | 717 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
718 | 718 | */ |
719 | - protected function getListItems( array $items, array $include ) |
|
719 | + protected function getListItems(array $items, array $include) |
|
720 | 720 | { |
721 | 721 | return array(); |
722 | 722 | } |
@@ -728,22 +728,22 @@ discard block |
||
728 | 728 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
729 | 729 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
730 | 730 | */ |
731 | - protected function getRefItems( array $listItems ) |
|
731 | + protected function getRefItems(array $listItems) |
|
732 | 732 | { |
733 | 733 | $list = $map = array(); |
734 | 734 | |
735 | - foreach( $listItems as $listItem ) { |
|
735 | + foreach ($listItems as $listItem) { |
|
736 | 736 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
737 | 737 | } |
738 | 738 | |
739 | - foreach( $map as $domain => $ids ) |
|
739 | + foreach ($map as $domain => $ids) |
|
740 | 740 | { |
741 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
741 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
742 | 742 | |
743 | 743 | $search = $manager->createSearch(); |
744 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
744 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
745 | 745 | |
746 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
746 | + $list = array_merge($list, $manager->searchItems($search)); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | return $list; |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | * @param \stdClass $request Decoded request body |
757 | 757 | * @return array List of item IDs |
758 | 758 | */ |
759 | - protected function getIds( $request ) |
|
759 | + protected function getIds($request) |
|
760 | 760 | { |
761 | 761 | $ids = array(); |
762 | 762 | |
763 | - if( isset( $request->data ) ) |
|
763 | + if (isset($request->data)) |
|
764 | 764 | { |
765 | - foreach( $request->data as $entry ) |
|
765 | + foreach ($request->data as $entry) |
|
766 | 766 | { |
767 | - if( isset( $entry->id ) ) { |
|
767 | + if (isset($entry->id)) { |
|
768 | 768 | $ids[] = $entry->id; |
769 | 769 | } |
770 | 770 | } |
@@ -816,30 +816,30 @@ discard block |
||
816 | 816 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
817 | 817 | * @return \Aimeos\MW\View\Iface Updated view instance |
818 | 818 | */ |
819 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
819 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
820 | 820 | { |
821 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
822 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
821 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
822 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
823 | 823 | } |
824 | 824 | |
825 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
825 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
826 | 826 | |
827 | - if( is_array( $request->data ) ) |
|
827 | + if (is_array($request->data)) |
|
828 | 828 | { |
829 | - $data = $this->saveData( $manager, $request ); |
|
829 | + $data = $this->saveData($manager, $request); |
|
830 | 830 | |
831 | 831 | $view->data = $data; |
832 | - $view->total = count( $data ); |
|
832 | + $view->total = count($data); |
|
833 | 833 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
834 | 834 | } |
835 | 835 | else |
836 | 836 | { |
837 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
838 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
837 | + if (($id = $view->param('id')) == null) { |
|
838 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | $request->data->id = $id; |
842 | - $data = $this->saveEntry( $manager, $request->data ); |
|
842 | + $data = $this->saveEntry($manager, $request->data); |
|
843 | 843 | |
844 | 844 | $view->data = $data; |
845 | 845 | $view->total = 1; |
@@ -857,31 +857,31 @@ discard block |
||
857 | 857 | * @param array &$header Associative list of HTTP headers as value/result parameter |
858 | 858 | * @return \Aimeos\MW\View\Iface Updated view instance |
859 | 859 | */ |
860 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
860 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
861 | 861 | { |
862 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
863 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
862 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
863 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
864 | 864 | } |
865 | 865 | |
866 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
867 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
866 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
867 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | |
871 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
871 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
872 | 872 | |
873 | - if( is_array( $request->data ) ) |
|
873 | + if (is_array($request->data)) |
|
874 | 874 | { |
875 | - $data = $this->saveData( $manager, $request ); |
|
875 | + $data = $this->saveData($manager, $request); |
|
876 | 876 | |
877 | 877 | $view->data = $data; |
878 | - $view->total = count( $data ); |
|
878 | + $view->total = count($data); |
|
879 | 879 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
880 | 880 | } |
881 | 881 | else |
882 | 882 | { |
883 | 883 | $request->data->id = null; |
884 | - $data = $this->saveEntry( $manager, $request->data ); |
|
884 | + $data = $this->saveEntry($manager, $request->data); |
|
885 | 885 | |
886 | 886 | $view->data = $data; |
887 | 887 | $view->total = 1; |
@@ -898,14 +898,14 @@ discard block |
||
898 | 898 | * @param \stdClass $request Object with request body data |
899 | 899 | * @return array List of items |
900 | 900 | */ |
901 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
901 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
902 | 902 | { |
903 | 903 | $data = array(); |
904 | 904 | |
905 | - if( isset( $request->data ) ) |
|
905 | + if (isset($request->data)) |
|
906 | 906 | { |
907 | - foreach( (array) $request->data as $entry ) { |
|
908 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
907 | + foreach ((array) $request->data as $entry) { |
|
908 | + $data[] = $this->saveEntry($manager, $entry); |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
@@ -920,24 +920,24 @@ discard block |
||
920 | 920 | * @param \stdClass $entry Object including "id" and "attributes" elements |
921 | 921 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
922 | 922 | */ |
923 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
923 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
924 | 924 | { |
925 | - $attr = ( isset( $entry->attributes ) ? (array) $entry->attributes : array() ); |
|
925 | + $attr = (isset($entry->attributes) ? (array) $entry->attributes : array()); |
|
926 | 926 | |
927 | - if( isset( $entry->id ) && $entry->id !== null ) { |
|
928 | - $item = $manager->getItem( $entry->id ); |
|
927 | + if (isset($entry->id) && $entry->id !== null) { |
|
928 | + $item = $manager->getItem($entry->id); |
|
929 | 929 | } else { |
930 | 930 | $item = $manager->createItem(); |
931 | 931 | } |
932 | 932 | |
933 | - $item->fromArray( $attr ); |
|
934 | - $manager->saveItem( $item ); |
|
933 | + $item->fromArray($attr); |
|
934 | + $manager->saveItem($item); |
|
935 | 935 | |
936 | - if( isset( $entry->relationships ) ) { |
|
937 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
936 | + if (isset($entry->relationships)) { |
|
937 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
938 | 938 | } |
939 | 939 | |
940 | - return $manager->getItem( $item->getId() ); |
|
940 | + return $manager->getItem($item->getId()); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | |
@@ -948,32 +948,32 @@ discard block |
||
948 | 948 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
949 | 949 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
950 | 950 | */ |
951 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
952 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
951 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
952 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
953 | 953 | { |
954 | 954 | $id = $item->getId(); |
955 | - $listManager = $manager->getSubManager( 'lists' ); |
|
955 | + $listManager = $manager->getSubManager('lists'); |
|
956 | 956 | |
957 | - foreach( (array) $relationships as $domain => $list ) |
|
957 | + foreach ((array) $relationships as $domain => $list) |
|
958 | 958 | { |
959 | - if( isset( $list->data ) ) |
|
959 | + if (isset($list->data)) |
|
960 | 960 | { |
961 | - foreach( (array) $list->data as $data ) |
|
961 | + foreach ((array) $list->data as $data) |
|
962 | 962 | { |
963 | 963 | $listItem = $listManager->createItem(); |
964 | 964 | |
965 | - if( isset( $data->attributes ) ) { |
|
966 | - $listItem->fromArray( (array) $data->attributes ); |
|
965 | + if (isset($data->attributes)) { |
|
966 | + $listItem->fromArray((array) $data->attributes); |
|
967 | 967 | } |
968 | 968 | |
969 | - if( isset( $data->id ) ) { |
|
970 | - $listItem->setRefId( $data->id ); |
|
969 | + if (isset($data->id)) { |
|
970 | + $listItem->setRefId($data->id); |
|
971 | 971 | } |
972 | 972 | |
973 | - $listItem->setParentId( $id ); |
|
974 | - $listItem->setDomain( $domain ); |
|
973 | + $listItem->setParentId($id); |
|
974 | + $listItem->setDomain($domain); |
|
975 | 975 | |
976 | - $listManager->saveItem( $listItem, false ); |
|
976 | + $listManager->saveItem($listItem, false); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | } |