@@ -171,8 +171,7 @@ discard block |
||
| 171 | 171 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 172 | 172 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 173 | 173 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 174 | - } |
|
| 175 | - else |
|
| 174 | + } else |
|
| 176 | 175 | { |
| 177 | 176 | $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
| 178 | 177 | $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
@@ -229,8 +228,7 @@ discard block |
||
| 229 | 228 | if( isset( $entry->parentid ) && $targetId !== null ) { |
| 230 | 229 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
| 231 | 230 | } |
| 232 | - } |
|
| 233 | - else |
|
| 231 | + } else |
|
| 234 | 232 | { |
| 235 | 233 | $item = $manager->createItem(); |
| 236 | 234 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 112 | 112 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 113 | 113 | */ |
| 114 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 114 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
| 115 | 115 | { |
| 116 | 116 | /** admin/jsonadm/partials/locale/site/template-data |
| 117 | 117 | * Relative path to the data partial template file for the locale site client |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @since 2016.07 |
| 129 | 129 | * @category Developer |
| 130 | 130 | */ |
| 131 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) ); |
|
| 131 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data')); |
|
| 132 | 132 | |
| 133 | - return parent::get( $request, $response ); |
|
| 133 | + return parent::get($request, $response); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | * @param array $include List of resource types that should be fetched |
| 142 | 142 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 143 | 143 | */ |
| 144 | - protected function getChildItems( array $items, array $include ) |
|
| 144 | + protected function getChildItems(array $items, array $include) |
|
| 145 | 145 | { |
| 146 | 146 | $list = array(); |
| 147 | 147 | |
| 148 | - if( in_array( 'locale/site', $include ) ) |
|
| 148 | + if (in_array('locale/site', $include)) |
|
| 149 | 149 | { |
| 150 | - foreach( $items as $item ) { |
|
| 151 | - $list = array_merge( $list, $item->getChildren() ); |
|
| 150 | + foreach ($items as $item) { |
|
| 151 | + $list = array_merge($list, $item->getChildren()); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
@@ -164,30 +164,30 @@ discard block |
||
| 164 | 164 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 165 | 165 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 166 | 166 | */ |
| 167 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 167 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 168 | 168 | { |
| 169 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
| 169 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
| 170 | 170 | |
| 171 | - if( ( $key = $view->param( 'aggregate' ) ) !== null ) |
|
| 171 | + if (($key = $view->param('aggregate')) !== null) |
|
| 172 | 172 | { |
| 173 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 174 | - $view->data = $manager->aggregate( $search, $key ); |
|
| 173 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 174 | + $view->data = $manager->aggregate($search, $key); |
|
| 175 | 175 | return $response; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 179 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 178 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 179 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 180 | 180 | $total = 1; |
| 181 | 181 | |
| 182 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 182 | + if (($id = $view->param('id')) == null) |
|
| 183 | 183 | { |
| 184 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 185 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 184 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 185 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 186 | 186 | } |
| 187 | 187 | else |
| 188 | 188 | { |
| 189 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
| 190 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
| 189 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
| 190 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $view->listItems = array(); |
@@ -205,32 +205,32 @@ discard block |
||
| 205 | 205 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 206 | 206 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 207 | 207 | */ |
| 208 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 208 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 209 | 209 | { |
| 210 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
| 211 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
| 210 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
| 211 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
| 212 | 212 | |
| 213 | - if( isset( $entry->id ) ) |
|
| 213 | + if (isset($entry->id)) |
|
| 214 | 214 | { |
| 215 | - $item = $manager->getItem( $entry->id ); |
|
| 216 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 217 | - $manager->saveItem( $item ); |
|
| 215 | + $item = $manager->getItem($entry->id); |
|
| 216 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 217 | + $manager->saveItem($item); |
|
| 218 | 218 | |
| 219 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
| 220 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
| 219 | + if (isset($entry->parentid) && $targetId !== null) { |
|
| 220 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| 225 | 225 | $item = $manager->createItem(); |
| 226 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 227 | - $manager->insertItem( $item, $targetId, $refId ); |
|
| 226 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 227 | + $manager->insertItem($item, $targetId, $refId); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if( isset( $entry->relationships ) ) { |
|
| 231 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 230 | + if (isset($entry->relationships)) { |
|
| 231 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - return $manager->getItem( $item->getId() ); |
|
| 234 | + return $manager->getItem($item->getId()); |
|
| 235 | 235 | } |
| 236 | 236 | } |
@@ -38,24 +38,21 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $view = $this->deleteItems( $view, $body ); |
| 40 | 40 | $status = 200; |
| 41 | - } |
|
| 42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 41 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 43 | 42 | { |
| 44 | 43 | $status = $e->getCode(); |
| 45 | 44 | $view->errors = array( array( |
| 46 | 45 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 47 | 46 | 'detail' => $e->getTraceAsString(), |
| 48 | 47 | ) ); |
| 49 | - } |
|
| 50 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 48 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 51 | 49 | { |
| 52 | 50 | $status = 404; |
| 53 | 51 | $view->errors = array( array( |
| 54 | 52 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 55 | 53 | 'detail' => $e->getTraceAsString(), |
| 56 | 54 | ) ); |
| 57 | - } |
|
| 58 | - catch( \Exception $e ) |
|
| 55 | + } catch( \Exception $e ) |
|
| 59 | 56 | { |
| 60 | 57 | $status = 500; |
| 61 | 58 | $view->errors = array( array( |
@@ -120,16 +117,14 @@ discard block |
||
| 120 | 117 | } |
| 121 | 118 | |
| 122 | 119 | $status = 200; |
| 123 | - } |
|
| 124 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 120 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 125 | 121 | { |
| 126 | 122 | $status = 404; |
| 127 | 123 | $view->errors = array( array( |
| 128 | 124 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 129 | 125 | 'detail' => $e->getTraceAsString(), |
| 130 | 126 | ) ); |
| 131 | - } |
|
| 132 | - catch( \Exception $e ) |
|
| 127 | + } catch( \Exception $e ) |
|
| 133 | 128 | { |
| 134 | 129 | $status = 500; |
| 135 | 130 | $view->errors = array( array( |
@@ -167,8 +162,7 @@ discard block |
||
| 167 | 162 | */ |
| 168 | 163 | $tplconf = 'admin/jsonadm/standard/template-aggregate'; |
| 169 | 164 | $default = 'aggregate-default.php'; |
| 170 | - } |
|
| 171 | - else |
|
| 165 | + } else |
|
| 172 | 166 | { |
| 173 | 167 | /** admin/jsonadm/standard/template-get |
| 174 | 168 | * Relative path to the JSON API template for GET requests |
@@ -220,24 +214,21 @@ discard block |
||
| 220 | 214 | { |
| 221 | 215 | $view = $this->patchItems( $view, $body, $header ); |
| 222 | 216 | $status = 200; |
| 223 | - } |
|
| 224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 217 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 225 | 218 | { |
| 226 | 219 | $status = $e->getCode(); |
| 227 | 220 | $view->errors = array( array( |
| 228 | 221 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 229 | 222 | 'detail' => $e->getTraceAsString(), |
| 230 | 223 | ) ); |
| 231 | - } |
|
| 232 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 224 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 233 | 225 | { |
| 234 | 226 | $status = 404; |
| 235 | 227 | $view->errors = array( array( |
| 236 | 228 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 237 | 229 | 'detail' => $e->getTraceAsString(), |
| 238 | 230 | ) ); |
| 239 | - } |
|
| 240 | - catch( \Exception $e ) |
|
| 231 | + } catch( \Exception $e ) |
|
| 241 | 232 | { |
| 242 | 233 | $status = 500; |
| 243 | 234 | $view->errors = array( array( |
@@ -295,24 +286,21 @@ discard block |
||
| 295 | 286 | { |
| 296 | 287 | $view = $this->postItems( $view, $body, $header ); |
| 297 | 288 | $status = 201; |
| 298 | - } |
|
| 299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 289 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 300 | 290 | { |
| 301 | 291 | $status = $e->getCode(); |
| 302 | 292 | $view->errors = array( array( |
| 303 | 293 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 304 | 294 | 'detail' => $e->getTraceAsString(), |
| 305 | 295 | ) ); |
| 306 | - } |
|
| 307 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 296 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 308 | 297 | { |
| 309 | 298 | $status = 404; |
| 310 | 299 | $view->errors = array( array( |
| 311 | 300 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 312 | 301 | 'detail' => $e->getTraceAsString(), |
| 313 | 302 | ) ); |
| 314 | - } |
|
| 315 | - catch( \Exception $e ) |
|
| 303 | + } catch( \Exception $e ) |
|
| 316 | 304 | { |
| 317 | 305 | $status = 500; |
| 318 | 306 | $view->errors = array( array( |
@@ -435,16 +423,14 @@ discard block |
||
| 435 | 423 | 'Allow' => 'DELETE,GET,PATCH,POST,OPTIONS' |
| 436 | 424 | ); |
| 437 | 425 | $status = 200; |
| 438 | - } |
|
| 439 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 426 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 440 | 427 | { |
| 441 | 428 | $status = 404; |
| 442 | 429 | $view->errors = array( array( |
| 443 | 430 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 444 | 431 | 'detail' => $e->getTraceAsString(), |
| 445 | 432 | ) ); |
| 446 | - } |
|
| 447 | - catch( \Exception $e ) |
|
| 433 | + } catch( \Exception $e ) |
|
| 448 | 434 | { |
| 449 | 435 | $status = 500; |
| 450 | 436 | $view->errors = array( array( |
@@ -506,8 +492,7 @@ discard block |
||
| 506 | 492 | $ids = $this->getIds( $request ); |
| 507 | 493 | $manager->deleteItems( $ids ); |
| 508 | 494 | $view->total = count( $ids ); |
| 509 | - } |
|
| 510 | - else |
|
| 495 | + } else |
|
| 511 | 496 | { |
| 512 | 497 | $manager->deleteItem( $id ); |
| 513 | 498 | $view->total = 1; |
@@ -554,8 +539,7 @@ discard block |
||
| 554 | 539 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 555 | 540 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 556 | 541 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 557 | - } |
|
| 558 | - else |
|
| 542 | + } else |
|
| 559 | 543 | { |
| 560 | 544 | $view->data = $manager->getItem( $id, array() ); |
| 561 | 545 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -605,16 +589,14 @@ discard block |
||
| 605 | 589 | $view->data = $data; |
| 606 | 590 | $view->total = count( $data ); |
| 607 | 591 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 608 | - } |
|
| 609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 592 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 610 | 593 | { |
| 611 | 594 | $request->data->id = $id; |
| 612 | 595 | $data = $this->saveEntry( $manager, $request->data ); |
| 613 | 596 | |
| 614 | 597 | $view->data = $data; |
| 615 | 598 | $view->total = 1; |
| 616 | - } |
|
| 617 | - else |
|
| 599 | + } else |
|
| 618 | 600 | { |
| 619 | 601 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
| 620 | 602 | } |
@@ -651,8 +633,7 @@ discard block |
||
| 651 | 633 | $view->data = $data; |
| 652 | 634 | $view->total = count( $data ); |
| 653 | 635 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 654 | - } |
|
| 655 | - else |
|
| 636 | + } else |
|
| 656 | 637 | { |
| 657 | 638 | $request->data->id = null; |
| 658 | 639 | $data = $this->saveEntry( $manager, $request->data ); |
@@ -31,38 +31,38 @@ discard block |
||
| 31 | 31 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 32 | 32 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 33 | 33 | */ |
| 34 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 34 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
| 35 | 35 | { |
| 36 | 36 | $view = $this->getView(); |
| 37 | 37 | |
| 38 | 38 | try |
| 39 | 39 | { |
| 40 | - $response = $this->deleteItems( $view, $request, $response ); |
|
| 40 | + $response = $this->deleteItems($view, $request, $response); |
|
| 41 | 41 | $status = 200; |
| 42 | 42 | } |
| 43 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 43 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 44 | 44 | { |
| 45 | 45 | $status = $e->getCode(); |
| 46 | - $view->errors = array( array( |
|
| 47 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 46 | + $view->errors = array(array( |
|
| 47 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 48 | 48 | 'detail' => $e->getTraceAsString(), |
| 49 | - ) ); |
|
| 49 | + )); |
|
| 50 | 50 | } |
| 51 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 51 | + catch (\Aimeos\MShop\Exception $e) |
|
| 52 | 52 | { |
| 53 | 53 | $status = 404; |
| 54 | - $view->errors = array( array( |
|
| 55 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 54 | + $view->errors = array(array( |
|
| 55 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 56 | 56 | 'detail' => $e->getTraceAsString(), |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | } |
| 59 | - catch( \Exception $e ) |
|
| 59 | + catch (\Exception $e) |
|
| 60 | 60 | { |
| 61 | 61 | $status = 500; |
| 62 | - $view->errors = array( array( |
|
| 62 | + $view->errors = array(array( |
|
| 63 | 63 | 'title' => $e->getMessage(), |
| 64 | 64 | 'detail' => $e->getTraceAsString(), |
| 65 | - ) ); |
|
| 65 | + )); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** admin/jsonadm/standard/template-delete |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
| 94 | 94 | $default = 'delete-default.php'; |
| 95 | 95 | |
| 96 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 96 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 97 | 97 | |
| 98 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 99 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 100 | - ->withStatus( $status ); |
|
| 98 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 99 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 100 | + ->withStatus($status); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
@@ -108,33 +108,33 @@ discard block |
||
| 108 | 108 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 109 | 109 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 110 | 110 | */ |
| 111 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 111 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
| 112 | 112 | { |
| 113 | 113 | $view = $this->getView(); |
| 114 | 114 | |
| 115 | 115 | try |
| 116 | 116 | { |
| 117 | - $response = $this->getItems( $view, $request, $response ); |
|
| 117 | + $response = $this->getItems($view, $request, $response); |
|
| 118 | 118 | $status = 200; |
| 119 | 119 | } |
| 120 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 120 | + catch (\Aimeos\MShop\Exception $e) |
|
| 121 | 121 | { |
| 122 | 122 | $status = 404; |
| 123 | - $view->errors = array( array( |
|
| 124 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 123 | + $view->errors = array(array( |
|
| 124 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 125 | 125 | 'detail' => $e->getTraceAsString(), |
| 126 | - ) ); |
|
| 126 | + )); |
|
| 127 | 127 | } |
| 128 | - catch( \Exception $e ) |
|
| 128 | + catch (\Exception $e) |
|
| 129 | 129 | { |
| 130 | 130 | $status = 500; |
| 131 | - $view->errors = array( array( |
|
| 131 | + $view->errors = array(array( |
|
| 132 | 132 | 'title' => $e->getMessage(), |
| 133 | 133 | 'detail' => $e->getTraceAsString(), |
| 134 | - ) ); |
|
| 134 | + )); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if( $view->param( 'aggregate' ) !== null ) |
|
| 137 | + if ($view->param('aggregate') !== null) |
|
| 138 | 138 | { |
| 139 | 139 | /** admin/jsonadm/standard/template-aggregate |
| 140 | 140 | * Relative path to the JSON API template for GET aggregate requests |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | $default = 'get-default.php'; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 198 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 199 | 199 | |
| 200 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 201 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 202 | - ->withStatus( $status ); |
|
| 200 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 201 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 202 | + ->withStatus($status); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | |
@@ -210,38 +210,38 @@ discard block |
||
| 210 | 210 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 211 | 211 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 212 | 212 | */ |
| 213 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 213 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
| 214 | 214 | { |
| 215 | 215 | $view = $this->getView(); |
| 216 | 216 | |
| 217 | 217 | try |
| 218 | 218 | { |
| 219 | - $response = $this->patchItems( $view, $request, $response ); |
|
| 219 | + $response = $this->patchItems($view, $request, $response); |
|
| 220 | 220 | $status = 200; |
| 221 | 221 | } |
| 222 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 222 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 223 | 223 | { |
| 224 | 224 | $status = $e->getCode(); |
| 225 | - $view->errors = array( array( |
|
| 226 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 225 | + $view->errors = array(array( |
|
| 226 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 227 | 227 | 'detail' => $e->getTraceAsString(), |
| 228 | - ) ); |
|
| 228 | + )); |
|
| 229 | 229 | } |
| 230 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 230 | + catch (\Aimeos\MShop\Exception $e) |
|
| 231 | 231 | { |
| 232 | 232 | $status = 404; |
| 233 | - $view->errors = array( array( |
|
| 234 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 233 | + $view->errors = array(array( |
|
| 234 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 235 | 235 | 'detail' => $e->getTraceAsString(), |
| 236 | - ) ); |
|
| 236 | + )); |
|
| 237 | 237 | } |
| 238 | - catch( \Exception $e ) |
|
| 238 | + catch (\Exception $e) |
|
| 239 | 239 | { |
| 240 | 240 | $status = 500; |
| 241 | - $view->errors = array( array( |
|
| 241 | + $view->errors = array(array( |
|
| 242 | 242 | 'title' => $e->getMessage(), |
| 243 | 243 | 'detail' => $e->getTraceAsString(), |
| 244 | - ) ); |
|
| 244 | + )); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** admin/jsonadm/standard/template-patch |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
| 273 | 273 | $default = 'patch-default.php'; |
| 274 | 274 | |
| 275 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 275 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 276 | 276 | |
| 277 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 278 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 279 | - ->withStatus( $status ); |
|
| 277 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 278 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 279 | + ->withStatus($status); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
@@ -287,38 +287,38 @@ discard block |
||
| 287 | 287 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 288 | 288 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 289 | 289 | */ |
| 290 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 290 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
| 291 | 291 | { |
| 292 | 292 | $view = $this->getView(); |
| 293 | 293 | |
| 294 | 294 | try |
| 295 | 295 | { |
| 296 | - $response = $this->postItems( $view, $request, $response ); |
|
| 296 | + $response = $this->postItems($view, $request, $response); |
|
| 297 | 297 | $status = 201; |
| 298 | 298 | } |
| 299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 299 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 300 | 300 | { |
| 301 | 301 | $status = $e->getCode(); |
| 302 | - $view->errors = array( array( |
|
| 303 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 302 | + $view->errors = array(array( |
|
| 303 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 304 | 304 | 'detail' => $e->getTraceAsString(), |
| 305 | - ) ); |
|
| 305 | + )); |
|
| 306 | 306 | } |
| 307 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 307 | + catch (\Aimeos\MShop\Exception $e) |
|
| 308 | 308 | { |
| 309 | 309 | $status = 404; |
| 310 | - $view->errors = array( array( |
|
| 311 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 310 | + $view->errors = array(array( |
|
| 311 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 312 | 312 | 'detail' => $e->getTraceAsString(), |
| 313 | - ) ); |
|
| 313 | + )); |
|
| 314 | 314 | } |
| 315 | - catch( \Exception $e ) |
|
| 315 | + catch (\Exception $e) |
|
| 316 | 316 | { |
| 317 | 317 | $status = 500; |
| 318 | - $view->errors = array( array( |
|
| 318 | + $view->errors = array(array( |
|
| 319 | 319 | 'title' => $e->getMessage(), |
| 320 | 320 | 'detail' => $e->getTraceAsString(), |
| 321 | - ) ); |
|
| 321 | + )); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** admin/jsonadm/standard/template-post |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | $tplconf = 'admin/jsonadm/standard/template-post'; |
| 350 | 350 | $default = 'post-default.php'; |
| 351 | 351 | |
| 352 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 352 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 353 | 353 | |
| 354 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 355 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 356 | - ->withStatus( $status ); |
|
| 354 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 355 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 356 | + ->withStatus($status); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | |
@@ -364,14 +364,14 @@ discard block |
||
| 364 | 364 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 365 | 365 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 366 | 366 | */ |
| 367 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 367 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
| 368 | 368 | { |
| 369 | 369 | $status = 501; |
| 370 | 370 | $view = $this->getView(); |
| 371 | 371 | |
| 372 | - $view->errors = array( array( |
|
| 373 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
| 374 | - ) ); |
|
| 372 | + $view->errors = array(array( |
|
| 373 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
| 374 | + )); |
|
| 375 | 375 | |
| 376 | 376 | /** admin/jsonadm/standard/template-put |
| 377 | 377 | * Relative path to the JSON API template for PUT requests |
@@ -401,11 +401,11 @@ discard block |
||
| 401 | 401 | $tplconf = 'admin/jsonadm/standard/template-put'; |
| 402 | 402 | $default = 'put-default.php'; |
| 403 | 403 | |
| 404 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 404 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 405 | 405 | |
| 406 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 407 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 408 | - ->withStatus( $status ); |
|
| 406 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 407 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 408 | + ->withStatus($status); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * @param string|null Form parameter prefix when nesting parameters is required |
| 418 | 418 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 419 | 419 | */ |
| 420 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
|
| 420 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null) |
|
| 421 | 421 | { |
| 422 | 422 | $context = $this->getContext(); |
| 423 | 423 | $view = $this->getView(); |
@@ -426,11 +426,11 @@ discard block |
||
| 426 | 426 | { |
| 427 | 427 | $resources = $attributes = array(); |
| 428 | 428 | |
| 429 | - foreach( $this->getDomains( $view ) as $domain ) |
|
| 429 | + foreach ($this->getDomains($view) as $domain) |
|
| 430 | 430 | { |
| 431 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 432 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
| 433 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
| 431 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 432 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
| 433 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | $view->prefix = $prefix; |
@@ -439,21 +439,21 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | $status = 200; |
| 441 | 441 | } |
| 442 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 442 | + catch (\Aimeos\MShop\Exception $e) |
|
| 443 | 443 | { |
| 444 | 444 | $status = 404; |
| 445 | - $view->errors = array( array( |
|
| 446 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 445 | + $view->errors = array(array( |
|
| 446 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 447 | 447 | 'detail' => $e->getTraceAsString(), |
| 448 | - ) ); |
|
| 448 | + )); |
|
| 449 | 449 | } |
| 450 | - catch( \Exception $e ) |
|
| 450 | + catch (\Exception $e) |
|
| 451 | 451 | { |
| 452 | 452 | $status = 500; |
| 453 | - $view->errors = array( array( |
|
| 453 | + $view->errors = array(array( |
|
| 454 | 454 | 'title' => $e->getMessage(), |
| 455 | 455 | 'detail' => $e->getTraceAsString(), |
| 456 | - ) ); |
|
| 456 | + )); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** admin/jsonadm/standard/template-options |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | $tplconf = 'admin/jsonadm/standard/template-options'; |
| 485 | 485 | $default = 'options-default.php'; |
| 486 | 486 | |
| 487 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
| 487 | + $body = $view->render($view->config($tplconf, $default)); |
|
| 488 | 488 | |
| 489 | - return $response->withHeader( 'Allow', 'DELETE,GET,PATCH,POST,OPTIONS' ) |
|
| 490 | - ->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
| 491 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
| 492 | - ->withStatus( $status ); |
|
| 489 | + return $response->withHeader('Allow', 'DELETE,GET,PATCH,POST,OPTIONS') |
|
| 490 | + ->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
| 491 | + ->withBody($view->response()->createStreamFromString($body)) |
|
| 492 | + ->withStatus($status); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
@@ -502,25 +502,25 @@ discard block |
||
| 502 | 502 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 503 | 503 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
| 504 | 504 | */ |
| 505 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 505 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 506 | 506 | { |
| 507 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 507 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 508 | 508 | |
| 509 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 509 | + if (($id = $view->param('id')) == null) |
|
| 510 | 510 | { |
| 511 | 511 | $body = (string) $request->getBody(); |
| 512 | 512 | |
| 513 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) || !is_array( $payload->data ) ) { |
|
| 514 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 513 | + if (($payload = json_decode($body)) === null || !isset($payload->data) || !is_array($payload->data)) { |
|
| 514 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - $ids = $this->getIds( $payload ); |
|
| 518 | - $manager->deleteItems( $ids ); |
|
| 519 | - $view->total = count( $ids ); |
|
| 517 | + $ids = $this->getIds($payload); |
|
| 518 | + $manager->deleteItems($ids); |
|
| 519 | + $view->total = count($ids); |
|
| 520 | 520 | } |
| 521 | 521 | else |
| 522 | 522 | { |
| 523 | - $manager->deleteItem( $id ); |
|
| 523 | + $manager->deleteItem($id); |
|
| 524 | 524 | $view->total = 1; |
| 525 | 525 | } |
| 526 | 526 | |
@@ -536,35 +536,35 @@ discard block |
||
| 536 | 536 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 537 | 537 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 538 | 538 | */ |
| 539 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 539 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 540 | 540 | { |
| 541 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 541 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 542 | 542 | |
| 543 | - if( ( $key = $view->param( 'aggregate' ) ) !== null ) |
|
| 543 | + if (($key = $view->param('aggregate')) !== null) |
|
| 544 | 544 | { |
| 545 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 546 | - $view->data = $manager->aggregate( $search, $key ); |
|
| 545 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 546 | + $view->data = $manager->aggregate($search, $key); |
|
| 547 | 547 | return $response; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $total = 1; |
| 551 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 551 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 552 | 552 | |
| 553 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 553 | + if (($id = $view->param('id')) == null) |
|
| 554 | 554 | { |
| 555 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 556 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 557 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 558 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 555 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 556 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 557 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 558 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 559 | 559 | } |
| 560 | 560 | else |
| 561 | 561 | { |
| 562 | - $view->data = $manager->getItem( $id, array() ); |
|
| 563 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
| 564 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 562 | + $view->data = $manager->getItem($id, array()); |
|
| 563 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
| 564 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 567 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 568 | 568 | $view->total = $total; |
| 569 | 569 | |
| 570 | 570 | return $response; |
@@ -580,35 +580,35 @@ discard block |
||
| 580 | 580 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 581 | 581 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
| 582 | 582 | */ |
| 583 | - protected function patchItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 583 | + protected function patchItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 584 | 584 | { |
| 585 | 585 | $body = (string) $request->getBody(); |
| 586 | 586 | |
| 587 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) { |
|
| 588 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 587 | + if (($payload = json_decode($body)) === null || !isset($payload->data)) { |
|
| 588 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 591 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 592 | 592 | |
| 593 | - if( is_array( $payload->data ) ) |
|
| 593 | + if (is_array($payload->data)) |
|
| 594 | 594 | { |
| 595 | - $data = $this->saveData( $manager, $payload ); |
|
| 595 | + $data = $this->saveData($manager, $payload); |
|
| 596 | 596 | |
| 597 | 597 | $view->data = $data; |
| 598 | - $view->total = count( $data ); |
|
| 599 | - $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
|
| 598 | + $view->total = count($data); |
|
| 599 | + $response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'); |
|
| 600 | 600 | } |
| 601 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 601 | + elseif (($id = $view->param('id')) != null) |
|
| 602 | 602 | { |
| 603 | 603 | $payload->data->id = $id; |
| 604 | - $data = $this->saveEntry( $manager, $payload->data ); |
|
| 604 | + $data = $this->saveEntry($manager, $payload->data); |
|
| 605 | 605 | |
| 606 | 606 | $view->data = $data; |
| 607 | 607 | $view->total = 1; |
| 608 | 608 | } |
| 609 | 609 | else |
| 610 | 610 | { |
| 611 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
| 611 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | return $response; |
@@ -623,33 +623,33 @@ discard block |
||
| 623 | 623 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 624 | 624 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 625 | 625 | */ |
| 626 | - protected function postItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 626 | + protected function postItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 627 | 627 | { |
| 628 | 628 | $body = (string) $request->getBody(); |
| 629 | 629 | |
| 630 | - if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) { |
|
| 631 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 630 | + if (($payload = json_decode($body)) === null || !isset($payload->data)) { |
|
| 631 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if( isset( $payload->data->id ) || $view->param( 'id' ) != null ) { |
|
| 635 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
| 634 | + if (isset($payload->data->id) || $view->param('id') != null) { |
|
| 635 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
| 639 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 639 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 640 | 640 | |
| 641 | - if( is_array( $payload->data ) ) |
|
| 641 | + if (is_array($payload->data)) |
|
| 642 | 642 | { |
| 643 | - $data = $this->saveData( $manager, $payload ); |
|
| 643 | + $data = $this->saveData($manager, $payload); |
|
| 644 | 644 | |
| 645 | 645 | $view->data = $data; |
| 646 | - $view->total = count( $data ); |
|
| 647 | - $response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' ); |
|
| 646 | + $view->total = count($data); |
|
| 647 | + $response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'); |
|
| 648 | 648 | } |
| 649 | 649 | else |
| 650 | 650 | { |
| 651 | 651 | $payload->data->id = null; |
| 652 | - $data = $this->saveEntry( $manager, $payload->data ); |
|
| 652 | + $data = $this->saveEntry($manager, $payload->data); |
|
| 653 | 653 | |
| 654 | 654 | $view->data = $data; |
| 655 | 655 | $view->total = 1; |
@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$data = $this->get( 'data', array() ); |
|
| 3 | +$data = $this->get('data', array()); |
|
| 4 | 4 | $entries = array(); |
| 5 | 5 | |
| 6 | -foreach( $data as $key => $value ) { |
|
| 7 | - $entries[] = array( 'id' => $key, 'type' => 'aggregate', 'attributes' => $value ); |
|
| 6 | +foreach ($data as $key => $value) { |
|
| 7 | + $entries[] = array('id' => $key, 'type' => 'aggregate', 'attributes' => $value); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | ?> |
| 11 | 11 | { |
| 12 | 12 | "meta": { |
| 13 | - "total": <?php echo count( $data ); ?> |
|
| 13 | + "total": <?php echo count($data); ?> |
|
| 14 | 14 | |
| 15 | 15 | }, |
| 16 | -<?php if( isset( $this->errors ) ) : ?> |
|
| 17 | - "errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
| 18 | -<?php elseif( isset( $this->data ) ) : ?> |
|
| 19 | - "data": <?php echo json_encode( $entries ); ?> |
|
| 16 | +<?php if (isset($this->errors)) : ?> |
|
| 17 | + "errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
| 18 | +<?php elseif (isset($this->data)) : ?> |
|
| 19 | + "data": <?php echo json_encode($entries); ?> |
|
| 20 | 20 | <?php endif; ?> |
| 21 | 21 | } |
@@ -107,20 +107,20 @@ discard block |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 109 | 109 | */ |
| 110 | - protected function getChildItems( array $items, array $include ) |
|
| 110 | + protected function getChildItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | 112 | $list = array(); |
| 113 | - $prodIds = array_keys( $items ); |
|
| 114 | - $include = array_intersect( $include, array( 'product/property' ) ); |
|
| 113 | + $prodIds = array_keys($items); |
|
| 114 | + $include = array_intersect($include, array('product/property')); |
|
| 115 | 115 | |
| 116 | - foreach( $include as $type ) |
|
| 116 | + foreach ($include as $type) |
|
| 117 | 117 | { |
| 118 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $type ); |
|
| 118 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $type); |
|
| 119 | 119 | |
| 120 | 120 | $search = $manager->createSearch(); |
| 121 | - $search->setConditions( $search->compare( '==', str_replace( '/', '.', $type ) . '.parentid', $prodIds ) ); |
|
| 121 | + $search->setConditions($search->compare('==', str_replace('/', '.', $type) . '.parentid', $prodIds)); |
|
| 122 | 122 | |
| 123 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
| 123 | + $list = array_merge($list, $manager->searchItems($search)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | return $list; |
@@ -134,17 +134,17 @@ discard block |
||
| 134 | 134 | * @param array $include List of resource types that should be fetched |
| 135 | 135 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 136 | 136 | */ |
| 137 | - protected function getListItems( array $items, array $include ) |
|
| 137 | + protected function getListItems(array $items, array $include) |
|
| 138 | 138 | { |
| 139 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 139 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 140 | 140 | |
| 141 | 141 | $search = $manager->createSearch(); |
| 142 | 142 | $expr = array( |
| 143 | - $search->compare( '==', 'product.lists.parentid', array_keys( $items ) ), |
|
| 144 | - $search->compare( '==', 'product.lists.domain', $include ), |
|
| 143 | + $search->compare('==', 'product.lists.parentid', array_keys($items)), |
|
| 144 | + $search->compare('==', 'product.lists.domain', $include), |
|
| 145 | 145 | ); |
| 146 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 146 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 147 | 147 | |
| 148 | - return $manager->searchItems( $search ); |
|
| 148 | + return $manager->searchItems($search); |
|
| 149 | 149 | } |
| 150 | 150 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->context = \TestHelperJadm::getContext(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,145 +30,145 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'catalog.code' => 'cafe' ) |
|
| 33 | + '==' => array('catalog.code' => 'cafe') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'text' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'catalog', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
| 51 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('catalog', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
| 51 | + $this->assertEquals(6, count($result['included'])); |
|
| 52 | 52 | |
| 53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 53 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | public function testGetTree() |
| 58 | 58 | { |
| 59 | 59 | $params = array( |
| 60 | - 'id' => $this->getCatalogItem( 'group' )->getId(), |
|
| 60 | + 'id' => $this->getCatalogItem('group')->getId(), |
|
| 61 | 61 | 'filter' => array( |
| 62 | - '==' => array( 'catalog.status' => 1 ) |
|
| 62 | + '==' => array('catalog.status' => 1) |
|
| 63 | 63 | ), |
| 64 | 64 | 'include' => 'catalog,text' |
| 65 | 65 | ); |
| 66 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 67 | - $this->view->addHelper( 'param', $helper ); |
|
| 66 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 67 | + $this->view->addHelper('param', $helper); |
|
| 68 | 68 | |
| 69 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 70 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 69 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 70 | + $result = json_decode((string) $response->getBody(), true); |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 74 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 73 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 74 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 75 | 75 | |
| 76 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 77 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 78 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
| 79 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
| 76 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 77 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 78 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
| 79 | + $this->assertEquals(2, count($result['included'])); |
|
| 80 | 80 | |
| 81 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 81 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | public function testPatch() |
| 86 | 86 | { |
| 87 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
| 87 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
| 88 | 88 | |
| 89 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
| 90 | - $stub->expects( $this->once() )->method( 'saveItem' ); |
|
| 91 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
| 92 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 89 | + $stub->expects($this->once())->method('moveItem'); |
|
| 90 | + $stub->expects($this->once())->method('saveItem'); |
|
| 91 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
| 92 | + ->will($this->returnValue($stub->createItem())); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | - $params = array( 'id' => '-1' ); |
|
| 96 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 97 | - $this->view->addHelper( 'param', $helper ); |
|
| 95 | + $params = array('id' => '-1'); |
|
| 96 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 97 | + $this->view->addHelper('param', $helper); |
|
| 98 | 98 | |
| 99 | 99 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
| 100 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 100 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 101 | 101 | |
| 102 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
| 103 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 102 | + $response = $this->object->patch($request, $this->view->response()); |
|
| 103 | + $result = json_decode((string) $response->getBody(), true); |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 107 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 106 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 107 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 108 | 108 | |
| 109 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 110 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 111 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 109 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 110 | + $this->assertArrayHasKey('data', $result); |
|
| 111 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 112 | 112 | |
| 113 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 114 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 113 | + $this->assertArrayNotHasKey('included', $result); |
|
| 114 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | public function testPost() |
| 119 | 119 | { |
| 120 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
| 120 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
| 121 | 121 | |
| 122 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
| 123 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 124 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
| 122 | + $stub->expects($this->any())->method('getItem') |
|
| 123 | + ->will($this->returnValue($stub->createItem())); |
|
| 124 | + $stub->expects($this->once())->method('insertItem'); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
| 128 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 128 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 129 | 129 | |
| 130 | - $response = $this->object->post( $request, $this->view->response() ); |
|
| 131 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 130 | + $response = $this->object->post($request, $this->view->response()); |
|
| 131 | + $result = json_decode((string) $response->getBody(), true); |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
| 135 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 134 | + $this->assertEquals(201, $response->getStatusCode()); |
|
| 135 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 136 | 136 | |
| 137 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 138 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 139 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 137 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 138 | + $this->assertArrayHasKey('data', $result); |
|
| 139 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 140 | 140 | |
| 141 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 142 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 141 | + $this->assertArrayNotHasKey('included', $result); |
|
| 142 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - protected function getCatalogItem( $code ) |
|
| 146 | + protected function getCatalogItem($code) |
|
| 147 | 147 | { |
| 148 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
| 148 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
| 149 | 149 | $search = $manager->createSearch(); |
| 150 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
| 151 | - $items = $manager->searchItems( $search ); |
|
| 150 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
| 151 | + $items = $manager->searchItems($search); |
|
| 152 | 152 | |
| 153 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 154 | - throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
| 153 | + if (($item = reset($items)) === false) { |
|
| 154 | + throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $item; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| 161 | - protected function getCatalogMock( array $methods ) |
|
| 161 | + protected function getCatalogMock(array $methods) |
|
| 162 | 162 | { |
| 163 | 163 | $name = 'ClientJsonAdmStandard'; |
| 164 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
| 164 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
| 165 | 165 | |
| 166 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
| 167 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 168 | - ->setMethods( $methods ) |
|
| 166 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
| 167 | + ->setConstructorArgs(array($this->context)) |
|
| 168 | + ->setMethods($methods) |
|
| 169 | 169 | ->getMock(); |
| 170 | 170 | |
| 171 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
| 171 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
| 172 | 172 | |
| 173 | 173 | return $stub; |
| 174 | 174 | } |
@@ -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\Supplier\Standard( $this->context, $this->view, $templatePaths, 'supplier' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Supplier\Standard($this->context, $this->view, $templatePaths, 'supplier'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,28 +30,28 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'supplier.code' => 'unitCode001' ) |
|
| 33 | + '==' => array('supplier.code' => 'unitCode001') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'text,supplier/address' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'supplier', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['text'] ) ); |
|
| 51 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['supplier/address'] ) ); |
|
| 52 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('supplier', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(3, count($result['data'][0]['relationships']['text'])); |
|
| 51 | + $this->assertEquals(1, count($result['data'][0]['relationships']['supplier/address'])); |
|
| 52 | + $this->assertEquals(4, count($result['included'])); |
|
| 53 | 53 | |
| 54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 54 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | 'sort' => 'supplier.id', |
| 65 | 65 | 'include' => 'supplier/address' |
| 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( 3, $result['meta']['total'] ); |
|
| 78 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
| 79 | - $this->assertEquals( 'supplier', $result['data'][0]['type'] ); |
|
| 80 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 81 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['supplier/address'] ) ); |
|
| 82 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
| 77 | + $this->assertEquals(3, $result['meta']['total']); |
|
| 78 | + $this->assertEquals(3, count($result['data'])); |
|
| 79 | + $this->assertEquals('supplier', $result['data'][0]['type']); |
|
| 80 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 81 | + $this->assertEquals(1, count($result['data'][0]['relationships']['supplier/address'])); |
|
| 82 | + $this->assertEquals(3, count($result['included'])); |
|
| 83 | 83 | |
| 84 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 84 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Order\Standard( $this->context, $this->view, $templatePaths, 'order' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Order\Standard($this->context, $this->view, $templatePaths, 'order'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,26 +30,26 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'order.editor' => 'core:unittest' ) |
|
| 33 | + '==' => array('order.editor' => 'core:unittest') |
|
| 34 | 34 | ), |
| 35 | 35 | 'aggregate' => 'order.cdate', |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'aggregate', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertGreaterThan( 0, count( $result['data'][0]['attributes'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('aggregate', $result['data'][0]['type']); |
|
| 50 | + $this->assertGreaterThan(0, count($result['data'][0]['attributes'])); |
|
| 51 | 51 | |
| 52 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 52 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -57,28 +57,28 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $params = array( |
| 59 | 59 | 'filter' => array( |
| 60 | - '==' => array( 'order.datepayment' => '2008-02-15 12:34:56' ) |
|
| 60 | + '==' => array('order.datepayment' => '2008-02-15 12:34:56') |
|
| 61 | 61 | ), |
| 62 | 62 | 'include' => 'order/base,order/status' |
| 63 | 63 | ); |
| 64 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 65 | - $this->view->addHelper( 'param', $helper ); |
|
| 64 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 65 | + $this->view->addHelper('param', $helper); |
|
| 66 | 66 | |
| 67 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 68 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 67 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 68 | + $result = json_decode((string) $response->getBody(), true); |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 72 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 71 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 72 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 73 | 73 | |
| 74 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 75 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 76 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
| 77 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
| 78 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base'] ) ); |
|
| 79 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
| 74 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 75 | + $this->assertEquals(1, count($result['data'])); |
|
| 76 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
| 77 | + $this->assertEquals(3, count($result['data'][0]['relationships']['order/status'])); |
|
| 78 | + $this->assertEquals(1, count($result['data'][0]['relationships']['order/base'])); |
|
| 79 | + $this->assertEquals(4, count($result['included'])); |
|
| 80 | 80 | |
| 81 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 81 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
@@ -91,23 +91,23 @@ discard block |
||
| 91 | 91 | 'sort' => 'order.id', |
| 92 | 92 | 'include' => 'order/status' |
| 93 | 93 | ); |
| 94 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 95 | - $this->view->addHelper( 'param', $helper ); |
|
| 94 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 95 | + $this->view->addHelper('param', $helper); |
|
| 96 | 96 | |
| 97 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 98 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 97 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 98 | + $result = json_decode((string) $response->getBody(), true); |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 102 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 101 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 102 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 103 | 103 | |
| 104 | - $this->assertGreaterThanOrEqual( 4, $result['meta']['total'] ); |
|
| 105 | - $this->assertGreaterThanOrEqual( 4, count( $result['data'] ) ); |
|
| 106 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
| 107 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 108 | - $this->assertGreaterThanOrEqual( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
| 109 | - $this->assertGreaterThanOrEqual( 11, count( $result['included'] ) ); |
|
| 104 | + $this->assertGreaterThanOrEqual(4, $result['meta']['total']); |
|
| 105 | + $this->assertGreaterThanOrEqual(4, count($result['data'])); |
|
| 106 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
| 107 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 108 | + $this->assertGreaterThanOrEqual(3, count($result['data'][0]['relationships']['order/status'])); |
|
| 109 | + $this->assertGreaterThanOrEqual(11, count($result['included'])); |
|
| 110 | 110 | |
| 111 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 111 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 112 | 112 | } |
| 113 | 113 | } |
@@ -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\Order\Base\Standard( $this->context, $this->view, $templatePaths, 'order/base' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Order\Base\Standard($this->context, $this->view, $templatePaths, 'order/base'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,28 +30,28 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'order.base.price' => '4800.00' ) |
|
| 33 | + '==' => array('order.base.price' => '4800.00') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'order/base/address,order/base/product' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'order/base', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base/address'] ) ); |
|
| 51 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['order/base/product'] ) ); |
|
| 52 | - $this->assertEquals( 7, count( $result['included'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('order/base', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(1, count($result['data'][0]['relationships']['order/base/address'])); |
|
| 51 | + $this->assertEquals(6, count($result['data'][0]['relationships']['order/base/product'])); |
|
| 52 | + $this->assertEquals(7, count($result['included'])); |
|
| 53 | 53 | |
| 54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 54 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | 'sort' => 'order.base.id', |
| 65 | 65 | 'include' => 'order/base/product' |
| 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->assertGreaterThanOrEqual( 4, $result['meta']['total'] ); |
|
| 78 | - $this->assertGreaterThanOrEqual( 4, count( $result['data'] ) ); |
|
| 79 | - $this->assertEquals( 'order/base', $result['data'][0]['type'] ); |
|
| 80 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 81 | - $this->assertGreaterThanOrEqual( 4, count( $result['data'][0]['relationships']['order/base/product'] ) ); |
|
| 82 | - $this->assertGreaterThanOrEqual( 14, count( $result['included'] ) ); |
|
| 77 | + $this->assertGreaterThanOrEqual(4, $result['meta']['total']); |
|
| 78 | + $this->assertGreaterThanOrEqual(4, count($result['data'])); |
|
| 79 | + $this->assertEquals('order/base', $result['data'][0]['type']); |
|
| 80 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 81 | + $this->assertGreaterThanOrEqual(4, count($result['data'][0]['relationships']['order/base/product'])); |
|
| 82 | + $this->assertGreaterThanOrEqual(14, count($result['included'])); |
|
| 83 | 83 | |
| 84 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 84 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Service\Standard( $this->context, $this->view, $templatePaths, 'service' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Service\Standard($this->context, $this->view, $templatePaths, 'service'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,26 +30,26 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'service.code' => 'unitpaymentcode' ) |
|
| 33 | + '==' => array('service.code' => 'unitpaymentcode') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'text' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'service', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['text'] ) ); |
|
| 51 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('service', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(3, count($result['data'][0]['relationships']['text'])); |
|
| 51 | + $this->assertEquals(3, 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 |