@@ -26,5 +26,5 @@ |
||
26 | 26 | * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object |
27 | 27 | * @param string $path Name of the client separated by slashes, e.g "order/base" |
28 | 28 | */ |
29 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, $path ); |
|
29 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, $path); |
|
30 | 30 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJadm::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Admin\JsonAdm\Price\Standard( $this->context, 'price' ); |
|
25 | - $this->object->setAimeos( \TestHelperJadm::getAimeos() ); |
|
26 | - $this->object->setView( $this->view ); |
|
24 | + $this->object = new \Aimeos\Admin\JsonAdm\Price\Standard($this->context, 'price'); |
|
25 | + $this->object->setAimeos(\TestHelperJadm::getAimeos()); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | { |
32 | 32 | $params = array( |
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'price.value' => '12.95' ) |
|
34 | + '==' => array('price.value' => '12.95') |
|
35 | 35 | ), |
36 | 36 | 'include' => 'attribute' |
37 | 37 | ); |
38 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
39 | - $this->view->addHelper( 'param', $helper ); |
|
38 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
39 | + $this->view->addHelper('param', $helper); |
|
40 | 40 | |
41 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
42 | - $result = json_decode( (string) $response->getBody(), true ); |
|
41 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
42 | + $result = json_decode((string) $response->getBody(), true); |
|
43 | 43 | |
44 | 44 | |
45 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
46 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
45 | + $this->assertEquals(200, $response->getStatusCode()); |
|
46 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
47 | 47 | |
48 | - $this->assertGreaterThan( 1, $result['meta']['total'] ); |
|
49 | - $this->assertGreaterThan( 1, count( $result['data'] ) ); |
|
50 | - $this->assertEquals( 'price', $result['data'][0]['type'] ); |
|
51 | - $this->assertEquals( 0, count( $result['data'][0]['relationships'] ) ); |
|
52 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
48 | + $this->assertGreaterThan(1, $result['meta']['total']); |
|
49 | + $this->assertGreaterThan(1, count($result['data'])); |
|
50 | + $this->assertEquals('price', $result['data'][0]['type']); |
|
51 | + $this->assertEquals(0, count($result['data'][0]['relationships'])); |
|
52 | + $this->assertEquals(0, count($result['included'])); |
|
53 | 53 | |
54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
54 | + $this->assertArrayNotHasKey('errors', $result); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object |
32 | 32 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
33 | 33 | */ |
34 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
34 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, $path) |
|
35 | 35 | { |
36 | 36 | $this->context = $context; |
37 | 37 | $this->path = $path; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param array $param List of method parameter |
46 | 46 | * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
47 | 47 | */ |
48 | - public function __call( $name, array $param ) |
|
48 | + public function __call($name, array $param) |
|
49 | 49 | { |
50 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
50 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getAimeos() |
60 | 60 | { |
61 | - if( !isset( $this->aimeos ) ) { |
|
62 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Aimeos object not available' ) ); |
|
61 | + if (!isset($this->aimeos)) { |
|
62 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Aimeos object not available')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $this->aimeos; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param \Aimeos\Bootstrap $aimeos The Aimeos bootstrap object |
73 | 73 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
74 | 74 | */ |
75 | - public function setAimeos( \Aimeos\Bootstrap $aimeos ) |
|
75 | + public function setAimeos(\Aimeos\Bootstrap $aimeos) |
|
76 | 76 | { |
77 | 77 | $this->aimeos = $aimeos; |
78 | 78 | return $this; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getView() |
88 | 88 | { |
89 | - if( !isset( $this->view ) ) { |
|
90 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No view available' ) ); |
|
89 | + if (!isset($this->view)) { |
|
90 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No view available')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $this->view; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output |
101 | 101 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
102 | 102 | */ |
103 | - public function setView( \Aimeos\MW\View\Iface $view ) |
|
103 | + public function setView(\Aimeos\MW\View\Iface $view) |
|
104 | 104 | { |
105 | 105 | $this->view = $view; |
106 | 106 | return $this; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $include List of resource types that should be fetched |
115 | 115 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
116 | 116 | */ |
117 | - protected function getChildItems( array $items, array $include ) |
|
117 | + protected function getChildItems(array $items, array $include) |
|
118 | 118 | { |
119 | 119 | return []; |
120 | 120 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
138 | 138 | * @return array List of domain names |
139 | 139 | */ |
140 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
140 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
141 | 141 | { |
142 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
142 | + if (($domains = $view->param('resource')) == '') |
|
143 | 143 | { |
144 | 144 | /** admin/jsonadm/domains |
145 | 145 | * A list of domain names whose clients are available for the JSON API |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order', |
163 | 163 | 'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text' |
164 | 164 | ); |
165 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
165 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return (array) $domains; |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | * @param \stdClass $request Decoded request body |
176 | 176 | * @return array List of item IDs |
177 | 177 | */ |
178 | - protected function getIds( $request ) |
|
178 | + protected function getIds($request) |
|
179 | 179 | { |
180 | 180 | $ids = []; |
181 | 181 | |
182 | - if( isset( $request->data ) ) |
|
182 | + if (isset($request->data)) |
|
183 | 183 | { |
184 | - foreach( (array) $request->data as $entry ) |
|
184 | + foreach ((array) $request->data as $entry) |
|
185 | 185 | { |
186 | - if( isset( $entry->id ) ) { |
|
186 | + if (isset($entry->id)) { |
|
187 | 187 | $ids[] = $entry->id; |
188 | 188 | } |
189 | 189 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param array $include List of resource types that should be fetched |
201 | 201 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
202 | 202 | */ |
203 | - protected function getListItems( array $items, array $include ) |
|
203 | + protected function getListItems(array $items, array $include) |
|
204 | 204 | { |
205 | 205 | return []; |
206 | 206 | } |
@@ -223,23 +223,23 @@ discard block |
||
223 | 223 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
224 | 224 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
225 | 225 | */ |
226 | - protected function getRefItems( array $listItems ) |
|
226 | + protected function getRefItems(array $listItems) |
|
227 | 227 | { |
228 | 228 | $list = $map = []; |
229 | 229 | $context = $this->getContext(); |
230 | 230 | |
231 | - foreach( $listItems as $listItem ) { |
|
231 | + foreach ($listItems as $listItem) { |
|
232 | 232 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
233 | 233 | } |
234 | 234 | |
235 | - foreach( $map as $domain => $ids ) |
|
235 | + foreach ($map as $domain => $ids) |
|
236 | 236 | { |
237 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
237 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
238 | 238 | |
239 | 239 | $search = $manager->createSearch(); |
240 | - $search->setConditions( $search->compare( '==', str_replace( '/', '.', $domain ) . '.id', $ids ) ); |
|
240 | + $search->setConditions($search->compare('==', str_replace('/', '.', $domain) . '.id', $ids)); |
|
241 | 241 | |
242 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
242 | + $list = array_merge($list, $manager->searchItems($search)); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return $list; |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * @param array List of all available resources |
254 | 254 | * @return array List of allowed resources |
255 | 255 | */ |
256 | - protected function getAllowedResources( \Aimeos\MW\View\Iface $view, array $resources ) |
|
256 | + protected function getAllowedResources(\Aimeos\MW\View\Iface $view, array $resources) |
|
257 | 257 | { |
258 | 258 | $config = $this->getContext()->getConfig(); |
259 | 259 | $allowed = []; |
260 | 260 | |
261 | - foreach( $resources as $resource ) |
|
261 | + foreach ($resources as $resource) |
|
262 | 262 | { |
263 | - if( $view->access( $config->get( 'admin/jsonadm/resource/' . $resource . '/groups', [] ) ) === true ) { |
|
263 | + if ($view->access($config->get('admin/jsonadm/resource/' . $resource . '/groups', [])) === true) { |
|
264 | 264 | $allowed[] = $resource; |
265 | 265 | } |
266 | 266 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
276 | 276 | * @return array List of domain names |
277 | 277 | */ |
278 | - protected function getResources( \Aimeos\MW\View\Iface $view ) |
|
278 | + protected function getResources(\Aimeos\MW\View\Iface $view) |
|
279 | 279 | { |
280 | 280 | /** admin/jsonadm/resources |
281 | 281 | * A list of additional resources name whose clients are available for the JSON API |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @category Developer |
294 | 294 | * @see admin/jsonadm/domains |
295 | 295 | */ |
296 | - return (array) $view->config( 'admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config'] ); |
|
296 | + return (array) $view->config('admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config']); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | * @param array $params List of criteria data with condition, sorting and paging |
305 | 305 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
306 | 306 | */ |
307 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
307 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
308 | 308 | { |
309 | - $this->initCriteriaConditions( $criteria, $params ); |
|
310 | - $this->initCriteriaSortations( $criteria, $params ); |
|
311 | - $this->initCriteriaSlice( $criteria, $params ); |
|
309 | + $this->initCriteriaConditions($criteria, $params); |
|
310 | + $this->initCriteriaSortations($criteria, $params); |
|
311 | + $this->initCriteriaSlice($criteria, $params); |
|
312 | 312 | |
313 | 313 | return $criteria; |
314 | 314 | } |
@@ -320,17 +320,17 @@ discard block |
||
320 | 320 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
321 | 321 | * @param array $params List of criteria data with condition, sorting and paging |
322 | 322 | */ |
323 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
323 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
324 | 324 | { |
325 | - if( !isset( $params['filter'] ) ) { |
|
325 | + if (!isset($params['filter'])) { |
|
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
329 | 329 | $existing = $criteria->getConditions(); |
330 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
330 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
331 | 331 | |
332 | - $expr = array( $criteria->getConditions(), $existing ); |
|
333 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
332 | + $expr = array($criteria->getConditions(), $existing); |
|
333 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
341 | 341 | * @param array $params List of criteria data with condition, sorting and paging |
342 | 342 | */ |
343 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
343 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
344 | 344 | { |
345 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
346 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
345 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
346 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
347 | 347 | |
348 | - $criteria->setSlice( $start, $size ); |
|
348 | + $criteria->setSlice($start, $size); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -355,24 +355,24 @@ discard block |
||
355 | 355 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
356 | 356 | * @param array $params List of criteria data with condition, sorting and paging |
357 | 357 | */ |
358 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
358 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
359 | 359 | { |
360 | - if( !isset( $params['sort'] ) ) { |
|
360 | + if (!isset($params['sort'])) { |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | 364 | $sortation = []; |
365 | 365 | |
366 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
366 | + foreach (explode(',', $params['sort']) as $sort) |
|
367 | 367 | { |
368 | - if( $sort[0] === '-' ) { |
|
369 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
368 | + if ($sort[0] === '-') { |
|
369 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
370 | 370 | } else { |
371 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
371 | + $sortation[] = $criteria->sort('+', $sort); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - $criteria->setSortations( $sortation ); |
|
375 | + $criteria->setSortations($sortation); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | * @param \stdClass $request Object with request body data |
384 | 384 | * @return array List of items |
385 | 385 | */ |
386 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
386 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
387 | 387 | { |
388 | 388 | $data = []; |
389 | 389 | |
390 | - if( isset( $request->data ) ) |
|
390 | + if (isset($request->data)) |
|
391 | 391 | { |
392 | - foreach( (array) $request->data as $entry ) { |
|
393 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
392 | + foreach ((array) $request->data as $entry) { |
|
393 | + $data[] = $this->saveEntry($manager, $entry); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
@@ -405,22 +405,22 @@ discard block |
||
405 | 405 | * @param \stdClass $entry Object including "id" and "attributes" elements |
406 | 406 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
407 | 407 | */ |
408 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
408 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
409 | 409 | { |
410 | - if( isset( $entry->id ) ) { |
|
411 | - $item = $manager->getItem( $entry->id ); |
|
410 | + if (isset($entry->id)) { |
|
411 | + $item = $manager->getItem($entry->id); |
|
412 | 412 | } else { |
413 | 413 | $item = $manager->createItem(); |
414 | 414 | } |
415 | 415 | |
416 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
417 | - $item = $manager->saveItem( $item ); |
|
416 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
417 | + $item = $manager->saveItem($item); |
|
418 | 418 | |
419 | - if( isset( $entry->relationships ) ) { |
|
420 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
419 | + if (isset($entry->relationships)) { |
|
420 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
421 | 421 | } |
422 | 422 | |
423 | - return $manager->getItem( $item->getId() ); |
|
423 | + return $manager->getItem($item->getId()); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | |
@@ -431,28 +431,28 @@ discard block |
||
431 | 431 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
432 | 432 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
433 | 433 | */ |
434 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
435 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
434 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
435 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
436 | 436 | { |
437 | 437 | $id = $item->getId(); |
438 | - $listManager = $manager->getSubManager( 'lists' ); |
|
438 | + $listManager = $manager->getSubManager('lists'); |
|
439 | 439 | |
440 | - foreach( (array) $relationships as $domain => $list ) |
|
440 | + foreach ((array) $relationships as $domain => $list) |
|
441 | 441 | { |
442 | - if( isset( $list->data ) ) |
|
442 | + if (isset($list->data)) |
|
443 | 443 | { |
444 | - foreach( (array) $list->data as $data ) |
|
444 | + foreach ((array) $list->data as $data) |
|
445 | 445 | { |
446 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
446 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
447 | 447 | |
448 | - if( isset( $data->id ) ) { |
|
449 | - $listItem->setRefId( $data->id ); |
|
448 | + if (isset($data->id)) { |
|
449 | + $listItem->setRefId($data->id); |
|
450 | 450 | } |
451 | 451 | |
452 | - $listItem->setParentId( $id ); |
|
453 | - $listItem->setDomain( $domain ); |
|
452 | + $listItem->setParentId($id); |
|
453 | + $listItem->setDomain($domain); |
|
454 | 454 | |
455 | - $listManager->saveItem( $listItem, false ); |
|
455 | + $listManager->saveItem($listItem, false); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
@@ -469,20 +469,20 @@ discard block |
||
469 | 469 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
470 | 470 | */ |
471 | 471 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
472 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
472 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
473 | 473 | { |
474 | - if( isset( $data->attributes ) ) |
|
474 | + if (isset($data->attributes)) |
|
475 | 475 | { |
476 | 476 | $attr = (array) $data->attributes; |
477 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
477 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
478 | 478 | |
479 | - if( isset( $attr[$key.'.type'] ) ) |
|
479 | + if (isset($attr[$key . '.type'])) |
|
480 | 480 | { |
481 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], [], $domain ); |
|
482 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
481 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], [], $domain); |
|
482 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
483 | 483 | } |
484 | 484 | |
485 | - $item->fromArray( $attr ); |
|
485 | + $item->fromArray($attr); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | return $item; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $classname Full name of the class for which the object should be returned |
32 | 32 | * @param \Aimeos\Admin\JsonAdm\Iface|null $client JSON API client object |
33 | 33 | */ |
34 | - public static function injectClient( $classname, \Aimeos\Admin\JsonAdm\Iface $client = null ) |
|
34 | + public static function injectClient($classname, \Aimeos\Admin\JsonAdm\Iface $client = null) |
|
35 | 35 | { |
36 | 36 | self::$objects[$classname] = $client; |
37 | 37 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
46 | 46 | * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object |
47 | 47 | */ |
48 | - protected static function addClientDecorators( \Aimeos\Admin\JsonAdm\Iface $client, |
|
49 | - \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
48 | + protected static function addClientDecorators(\Aimeos\Admin\JsonAdm\Iface $client, |
|
49 | + \Aimeos\MShop\Context\Item\Iface $context, $path) |
|
50 | 50 | { |
51 | 51 | $config = $context->getConfig(); |
52 | 52 | |
@@ -72,38 +72,38 @@ discard block |
||
72 | 72 | * @since 2015.12 |
73 | 73 | * @category Developer |
74 | 74 | */ |
75 | - $decorators = $config->get( 'admin/jsonadm/common/decorators/default', [] ); |
|
75 | + $decorators = $config->get('admin/jsonadm/common/decorators/default', []); |
|
76 | 76 | |
77 | - if( $path !== null && is_string( $path ) ) |
|
77 | + if ($path !== null && is_string($path)) |
|
78 | 78 | { |
79 | - $dpath = trim( $path, '/' ); |
|
80 | - $dpath = ( $dpath !== '' ? $dpath . '/' : $dpath ); |
|
79 | + $dpath = trim($path, '/'); |
|
80 | + $dpath = ($dpath !== '' ? $dpath . '/' : $dpath); |
|
81 | 81 | |
82 | - $excludes = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/excludes', [] ); |
|
83 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) ); |
|
82 | + $excludes = $config->get('admin/jsonadm/' . $dpath . 'decorators/excludes', []); |
|
83 | + $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path))); |
|
84 | 84 | |
85 | - foreach( $decorators as $key => $name ) |
|
85 | + foreach ($decorators as $key => $name) |
|
86 | 86 | { |
87 | - if( in_array( $name, $excludes ) ) { |
|
88 | - unset( $decorators[$key] ); |
|
87 | + if (in_array($name, $excludes)) { |
|
88 | + unset($decorators[$key]); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | $classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\'; |
93 | - $decorators = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/global', [] ); |
|
94 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $path ); |
|
93 | + $decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/global', []); |
|
94 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $path); |
|
95 | 95 | |
96 | - if( !empty( $path ) ) |
|
96 | + if (!empty($path)) |
|
97 | 97 | { |
98 | - $classprefix = '\\Aimeos\\Admin\\JsonAdm\\' . ucfirst( $localClass ) . '\\Decorator\\'; |
|
99 | - $decorators = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/local', [] ); |
|
100 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $path ); |
|
98 | + $classprefix = '\\Aimeos\\Admin\\JsonAdm\\' . ucfirst($localClass) . '\\Decorator\\'; |
|
99 | + $decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/local', []); |
|
100 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $path); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | else |
104 | 104 | { |
105 | 105 | $classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\'; |
106 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $path ); |
|
106 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $path); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return $client; |
@@ -120,26 +120,26 @@ discard block |
||
120 | 120 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
121 | 121 | * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object |
122 | 122 | */ |
123 | - protected static function addDecorators( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
124 | - \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
123 | + protected static function addDecorators(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
124 | + \Aimeos\MShop\Context\Item\Iface $context, $path) |
|
125 | 125 | { |
126 | - foreach( $decorators as $name ) |
|
126 | + foreach ($decorators as $name) |
|
127 | 127 | { |
128 | - if( ctype_alnum( $name ) === false ) |
|
128 | + if (ctype_alnum($name) === false) |
|
129 | 129 | { |
130 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
131 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ), 404 ); |
|
130 | + $classname = is_string($name) ? $classprefix . $name : '<not a string>'; |
|
131 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname), 404); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $classname = $classprefix . $name; |
135 | 135 | |
136 | - if( class_exists( $classname ) === false ) { |
|
137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 ); |
|
136 | + if (class_exists($classname) === false) { |
|
137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Class "%1$s" not found', $classname), 404); |
|
138 | 138 | } |
139 | 139 | |
140 | - $client = new $classname( $client, $context, $path ); |
|
140 | + $client = new $classname($client, $context, $path); |
|
141 | 141 | |
142 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\Iface', $client ); |
|
142 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\Iface', $client); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
156 | 156 | * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object |
157 | 157 | */ |
158 | - protected static function createClientBase( $classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
158 | + protected static function createClientBase($classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, $path) |
|
159 | 159 | { |
160 | - if( isset( self::$objects[$classname] ) ) { |
|
160 | + if (isset(self::$objects[$classname])) { |
|
161 | 161 | return self::$objects[$classname]; |
162 | 162 | } |
163 | 163 | |
164 | - if( class_exists( $classname ) === false ) { |
|
165 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 ); |
|
164 | + if (class_exists($classname) === false) { |
|
165 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Class "%1$s" not found', $classname), 404); |
|
166 | 166 | } |
167 | 167 | |
168 | - $client = new $classname( $context, $path ); |
|
168 | + $client = new $classname($context, $path); |
|
169 | 169 | |
170 | - \Aimeos\MW\Common\Base::checkClass( $interface, $client ); |
|
170 | + \Aimeos\MW\Common\Base::checkClass($interface, $client); |
|
171 | 171 | |
172 | 172 | return $client; |
173 | 173 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJadm::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard( $this->context, 'product' ); |
|
25 | - $this->object->setAimeos( \TestHelperJadm::getAimeos() ); |
|
26 | - $this->object->setView( $this->view ); |
|
24 | + $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, 'product'); |
|
25 | + $this->object->setAimeos(\TestHelperJadm::getAimeos()); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,33 +31,33 @@ discard block |
||
31 | 31 | { |
32 | 32 | $params = array( |
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'product.code' => 'CNE' ) |
|
34 | + '==' => array('product.code' => 'CNE') |
|
35 | 35 | ), |
36 | 36 | 'include' => 'text,product,product/property' |
37 | 37 | ); |
38 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
39 | - $this->view->addHelper( 'param', $helper ); |
|
40 | - |
|
41 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
42 | - $result = json_decode( (string) $response->getBody(), true ); |
|
43 | - |
|
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
46 | - |
|
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 7, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['text'][0]['data']['links'] ); |
|
52 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
53 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['product'][0]['data']['links'] ); |
|
54 | - $this->assertEquals( 4, count( $result['data'][0]['relationships']['product/property'] ) ); |
|
55 | - $this->assertEquals( 15, count( $result['included'] ) ); |
|
56 | - $this->assertEquals( 'product/property', $result['included'][0]['type'] ); |
|
57 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
58 | - $this->assertArrayHaskey( 'related', $result['included'][0]['links'] ); |
|
59 | - |
|
60 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
38 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
39 | + $this->view->addHelper('param', $helper); |
|
40 | + |
|
41 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
42 | + $result = json_decode((string) $response->getBody(), true); |
|
43 | + |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | + |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(7, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['text'][0]['data']['links']); |
|
52 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
53 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['product'][0]['data']['links']); |
|
54 | + $this->assertEquals(4, count($result['data'][0]['relationships']['product/property'])); |
|
55 | + $this->assertEquals(15, count($result['included'])); |
|
56 | + $this->assertEquals('product/property', $result['included'][0]['type']); |
|
57 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
58 | + $this->assertArrayHaskey('related', $result['included'][0]['links']); |
|
59 | + |
|
60 | + $this->assertArrayNotHasKey('errors', $result); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | 'sort' => 'product.code', |
71 | 71 | 'include' => 'product,product/property' |
72 | 72 | ); |
73 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
74 | - $this->view->addHelper( 'param', $helper ); |
|
73 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
74 | + $this->view->addHelper('param', $helper); |
|
75 | 75 | |
76 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
77 | - $result = json_decode( (string) $response->getBody(), true ); |
|
76 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
77 | + $result = json_decode((string) $response->getBody(), true); |
|
78 | 78 | |
79 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
80 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
79 | + $this->assertEquals(200, $response->getStatusCode()); |
|
80 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
81 | 81 | |
82 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
83 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
84 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
85 | - $this->assertEquals( 3, count( $result['data'][0]['attributes'] ) ); |
|
86 | - $this->assertEquals( 5, count( $result['data'][8]['relationships']['product'] ) ); |
|
87 | - $this->assertEquals( 21, count( $result['included'] ) ); |
|
82 | + $this->assertEquals(28, $result['meta']['total']); |
|
83 | + $this->assertEquals(25, count($result['data'])); |
|
84 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
85 | + $this->assertEquals(3, count($result['data'][0]['attributes'])); |
|
86 | + $this->assertEquals(5, count($result['data'][8]['relationships']['product'])); |
|
87 | + $this->assertEquals(21, count($result['included'])); |
|
88 | 88 | |
89 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
89 | + $this->assertArrayNotHasKey('errors', $result); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJadm::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Admin\JsonAdm\Media\Standard( $this->context, 'media' ); |
|
25 | - $this->object->setAimeos( \TestHelperJadm::getAimeos() ); |
|
26 | - $this->object->setView( $this->view ); |
|
24 | + $this->object = new \Aimeos\Admin\JsonAdm\Media\Standard($this->context, 'media'); |
|
25 | + $this->object->setAimeos(\TestHelperJadm::getAimeos()); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | { |
32 | 32 | $params = array( |
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'media.label' => 'prod_179x178/196_prod_179x178.jpg' ) |
|
34 | + '==' => array('media.label' => 'prod_179x178/196_prod_179x178.jpg') |
|
35 | 35 | ), |
36 | 36 | 'include' => 'attribute' |
37 | 37 | ); |
38 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
39 | - $this->view->addHelper( 'param', $helper ); |
|
38 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
39 | + $this->view->addHelper('param', $helper); |
|
40 | 40 | |
41 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
42 | - $result = json_decode( (string) $response->getBody(), true ); |
|
41 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
42 | + $result = json_decode((string) $response->getBody(), true); |
|
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'media', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['attribute'] ) ); |
|
51 | - $this->assertEquals( 1, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('media', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(1, count($result['data'][0]['relationships']['attribute'])); |
|
51 | + $this->assertEquals(1, count($result['included'])); |
|
52 | 52 | |
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJadm::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Admin\JsonAdm\Supplier\Standard( $this->context, 'supplier' ); |
|
25 | - $this->object->setAimeos( \TestHelperJadm::getAimeos() ); |
|
26 | - $this->object->setView( $this->view ); |
|
24 | + $this->object = new \Aimeos\Admin\JsonAdm\Supplier\Standard($this->context, 'supplier'); |
|
25 | + $this->object->setAimeos(\TestHelperJadm::getAimeos()); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,28 +31,28 @@ discard block |
||
31 | 31 | { |
32 | 32 | $params = array( |
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'supplier.code' => 'unitCode001' ) |
|
34 | + '==' => array('supplier.code' => 'unitCode001') |
|
35 | 35 | ), |
36 | 36 | 'include' => 'text,supplier/address' |
37 | 37 | ); |
38 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
39 | - $this->view->addHelper( 'param', $helper ); |
|
38 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
39 | + $this->view->addHelper('param', $helper); |
|
40 | 40 | |
41 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
42 | - $result = json_decode( (string) $response->getBody(), true ); |
|
41 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
42 | + $result = json_decode((string) $response->getBody(), true); |
|
43 | 43 | |
44 | 44 | |
45 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
46 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
45 | + $this->assertEquals(200, $response->getStatusCode()); |
|
46 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
47 | 47 | |
48 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
49 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
50 | - $this->assertEquals( 'supplier', $result['data'][0]['type'] ); |
|
51 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['text'] ) ); |
|
52 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['supplier/address'] ) ); |
|
53 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
48 | + $this->assertEquals(1, $result['meta']['total']); |
|
49 | + $this->assertEquals(1, count($result['data'])); |
|
50 | + $this->assertEquals('supplier', $result['data'][0]['type']); |
|
51 | + $this->assertEquals(3, count($result['data'][0]['relationships']['text'])); |
|
52 | + $this->assertEquals(1, count($result['data'][0]['relationships']['supplier/address'])); |
|
53 | + $this->assertEquals(4, count($result['included'])); |
|
54 | 54 | |
55 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
55 | + $this->assertArrayNotHasKey('errors', $result); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $params = array( |
62 | 62 | 'filter' => array( |
63 | - '=~' => array( 'supplier.code' => 'unitCode00' ) |
|
63 | + '=~' => array('supplier.code' => 'unitCode00') |
|
64 | 64 | ), |
65 | 65 | 'fields' => array( |
66 | 66 | 'supplier' => 'supplier.id,supplier.label' |
@@ -68,23 +68,23 @@ discard block |
||
68 | 68 | 'sort' => 'supplier.id', |
69 | 69 | 'include' => 'supplier/address' |
70 | 70 | ); |
71 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
72 | - $this->view->addHelper( 'param', $helper ); |
|
71 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
72 | + $this->view->addHelper('param', $helper); |
|
73 | 73 | |
74 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
75 | - $result = json_decode( (string) $response->getBody(), true ); |
|
74 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
75 | + $result = json_decode((string) $response->getBody(), true); |
|
76 | 76 | |
77 | 77 | |
78 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
79 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
78 | + $this->assertEquals(200, $response->getStatusCode()); |
|
79 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
80 | 80 | |
81 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
82 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
83 | - $this->assertEquals( 'supplier', $result['data'][0]['type'] ); |
|
84 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
85 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['supplier/address'] ) ); |
|
86 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
81 | + $this->assertEquals(3, $result['meta']['total']); |
|
82 | + $this->assertEquals(3, count($result['data'])); |
|
83 | + $this->assertEquals('supplier', $result['data'][0]['type']); |
|
84 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
85 | + $this->assertEquals(1, count($result['data'][0]['relationships']['supplier/address'])); |
|
86 | + $this->assertEquals(3, count($result['included'])); |
|
87 | 87 | |
88 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
88 | + $this->assertArrayNotHasKey('errors', $result); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJadm::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Standard( $this->context, 'coupon' ); |
|
25 | - $this->object->setAimeos( \TestHelperJadm::getAimeos() ); |
|
26 | - $this->object->setView( $this->view ); |
|
24 | + $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Standard($this->context, 'coupon'); |
|
25 | + $this->object->setAimeos(\TestHelperJadm::getAimeos()); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | { |
32 | 32 | $params = array( |
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'coupon.code.code' => '90AB' ) |
|
34 | + '==' => array('coupon.code.code' => '90AB') |
|
35 | 35 | ), |
36 | 36 | 'include' => 'coupon/code' |
37 | 37 | ); |
38 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
39 | - $this->view->addHelper( 'param', $helper ); |
|
38 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
39 | + $this->view->addHelper('param', $helper); |
|
40 | 40 | |
41 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
42 | - $result = json_decode( (string) $response->getBody(), true ); |
|
41 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
42 | + $result = json_decode((string) $response->getBody(), true); |
|
43 | 43 | |
44 | 44 | |
45 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
46 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
45 | + $this->assertEquals(200, $response->getStatusCode()); |
|
46 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
47 | 47 | |
48 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
49 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
50 | - $this->assertEquals( 'coupon', $result['data'][0]['type'] ); |
|
51 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['coupon/code'] ) ); |
|
52 | - $this->assertEquals( 1, count( $result['included'] ) ); |
|
48 | + $this->assertEquals(1, $result['meta']['total']); |
|
49 | + $this->assertEquals(1, count($result['data'])); |
|
50 | + $this->assertEquals('coupon', $result['data'][0]['type']); |
|
51 | + $this->assertEquals(1, count($result['data'][0]['relationships']['coupon/code'])); |
|
52 | + $this->assertEquals(1, count($result['included'])); |
|
53 | 53 | |
54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
54 | + $this->assertArrayNotHasKey('errors', $result); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -64,22 +64,22 @@ discard block |
||
64 | 64 | 'sort' => 'coupon.id', |
65 | 65 | 'include' => 'coupon/code' |
66 | 66 | ); |
67 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
68 | - $this->view->addHelper( 'param', $helper ); |
|
67 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
68 | + $this->view->addHelper('param', $helper); |
|
69 | 69 | |
70 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
71 | - $result = json_decode( (string) $response->getBody(), true ); |
|
70 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
71 | + $result = json_decode((string) $response->getBody(), true); |
|
72 | 72 | |
73 | 73 | |
74 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
75 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
74 | + $this->assertEquals(200, $response->getStatusCode()); |
|
75 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
76 | 76 | |
77 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
78 | - $this->assertEquals( 6, count( $result['data'] ) ); |
|
79 | - $this->assertEquals( 'coupon', $result['data'][0]['type'] ); |
|
80 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
81 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['coupon/code'] ) ); |
|
82 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
83 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
77 | + $this->assertEquals(6, $result['meta']['total']); |
|
78 | + $this->assertEquals(6, count($result['data'])); |
|
79 | + $this->assertEquals('coupon', $result['data'][0]['type']); |
|
80 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
81 | + $this->assertEquals(1, count($result['data'][0]['relationships']['coupon/code'])); |
|
82 | + $this->assertEquals(6, count($result['included'])); |
|
83 | + $this->assertArrayNotHasKey('errors', $result); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | \ No newline at end of file |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | $view = $this->getView(); |
116 | 116 | |
117 | 117 | try |
118 | 118 | { |
119 | - $response = $this->getItems( $view, $request, $response ); |
|
119 | + $response = $this->getItems($view, $request, $response); |
|
120 | 120 | $status = 200; |
121 | 121 | } |
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
122 | + catch (\Aimeos\MShop\Exception $e) |
|
123 | 123 | { |
124 | 124 | $status = 404; |
125 | - $view->errors = array( array( |
|
126 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
125 | + $view->errors = array(array( |
|
126 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
127 | 127 | 'detail' => $e->getTraceAsString(), |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | - catch( \Exception $e ) |
|
130 | + catch (\Exception $e) |
|
131 | 131 | { |
132 | 132 | $status = 500; |
133 | - $view->errors = array( array( |
|
133 | + $view->errors = array(array( |
|
134 | 134 | 'title' => $e->getMessage(), |
135 | 135 | 'detail' => $e->getTraceAsString(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** admin/jsonadm/service/config/template-get |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $tplconf = 'admin/jsonadm/service/config/template-get'; |
159 | 159 | $default = 'config-standard'; |
160 | 160 | |
161 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
161 | + $body = $view->render($view->config($tplconf, $default)); |
|
162 | 162 | |
163 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
164 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
165 | - ->withStatus( $status ); |
|
163 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
164 | + ->withBody($view->response()->createStreamFromString($body)) |
|
165 | + ->withStatus($status); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
175 | 175 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
176 | 176 | */ |
177 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
177 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
178 | 178 | { |
179 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
180 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
179 | + if (($id = $view->param('id')) == null) { |
|
180 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
181 | 181 | } |
182 | 182 | |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
184 | - $item = $manager->createItem()->setProvider( $id ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
184 | + $item = $manager->createItem()->setProvider($id); |
|
185 | 185 | |
186 | - $view->configItems = $manager->getProvider( $item, $view->param( 'type', 'payment' ) )->getConfigBE(); |
|
186 | + $view->configItems = $manager->getProvider($item, $view->param('type', 'payment'))->getConfigBE(); |
|
187 | 187 | |
188 | 188 | return $response; |
189 | 189 | } |