@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $baseId = $item->getBaseId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,25 +27,25 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $childItems as $childId => $childItem ) |
|
35 | + foreach ($childItems as $childId => $childItem) |
|
36 | 36 | { |
37 | - if( $childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
37 | + if ($childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
38 | 38 | || $childItem instanceof \Aimeos\MShop\Order\Item\Base\Iface && $childItem->getId() == $baseId |
39 | 39 | ) { |
40 | 40 | $type = $childItem->getResourceType(); |
41 | - $params = array( 'resource' => $childItem->getResourceType(), 'id' => $childId ); |
|
41 | + $params = array('resource' => $childItem->getResourceType(), 'id' => $childId); |
|
42 | 42 | |
43 | - $result['relationships'][$type][] = array( 'data' => array( |
|
43 | + $result['relationships'][$type][] = array('data' => array( |
|
44 | 44 | 'id' => $childId, 'type' => $type, |
45 | 45 | 'links' => array( |
46 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
46 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
47 | 47 | ) |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -53,27 +53,27 @@ discard block |
||
53 | 53 | }; |
54 | 54 | |
55 | 55 | |
56 | -$fields = $this->param( 'fields', array() ); |
|
56 | +$fields = $this->param('fields', array()); |
|
57 | 57 | |
58 | -foreach( (array) $fields as $resource => $list ) { |
|
59 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
58 | +foreach ((array) $fields as $resource => $list) { |
|
59 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | -$data = $this->get( 'data', array() ); |
|
64 | -$childItems = $this->get( 'childItems', array() ); |
|
63 | +$data = $this->get('data', array()); |
|
64 | +$childItems = $this->get('childItems', array()); |
|
65 | 65 | |
66 | -if( is_array( $data ) ) |
|
66 | +if (is_array($data)) |
|
67 | 67 | { |
68 | 68 | $response = array(); |
69 | 69 | |
70 | - foreach( $data as $item ) { |
|
71 | - $response[] = $build( $this, $item, $fields, $childItems ); |
|
70 | + foreach ($data as $item) { |
|
71 | + $response[] = $build($this, $item, $fields, $childItems); |
|
72 | 72 | } |
73 | 73 | } |
74 | -elseif( $data !== null ) |
|
74 | +elseif ($data !== null) |
|
75 | 75 | { |
76 | - $response = $build( $this, $data, $fields, $childItems ); |
|
76 | + $response = $build($this, $data, $fields, $childItems); |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
@@ -81,4 +81,4 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | -echo json_encode( $response, $options ); |
|
85 | 84 | \ No newline at end of file |
85 | +echo json_encode($response, $options); |
|
86 | 86 | \ No newline at end of file |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Base\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Base\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $attributes = $item->toArray(); |
12 | 12 | $type = $item->getResourceType(); |
13 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
13 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
14 | 14 | |
15 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
16 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
17 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
18 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
15 | + $target = $view->config('admin/jsonadm/url/target'); |
|
16 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
17 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
18 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
19 | 19 | |
20 | - if( isset( $fields[$type] ) ) { |
|
21 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
20 | + if (isset($fields[$type])) { |
|
21 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | $result = array( |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | 'type' => $type, |
27 | 27 | 'attributes' => $attributes, |
28 | 28 | 'links' => array( |
29 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
29 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
30 | 30 | ), |
31 | 31 | 'relationships' => array() |
32 | 32 | ); |
33 | 33 | |
34 | - foreach( $childItems as $childId => $childItem ) |
|
34 | + foreach ($childItems as $childId => $childItem) |
|
35 | 35 | { |
36 | - if( $childItem->getBaseId() == $id ) |
|
36 | + if ($childItem->getBaseId() == $id) |
|
37 | 37 | { |
38 | 38 | $type = $childItem->getResourceType(); |
39 | - $params = array( 'resource' => $childItem->getResourceType(), 'id' => $childId ); |
|
39 | + $params = array('resource' => $childItem->getResourceType(), 'id' => $childId); |
|
40 | 40 | |
41 | - $result['relationships'][$type][] = array( 'data' => array( |
|
41 | + $result['relationships'][$type][] = array('data' => array( |
|
42 | 42 | 'id' => $childId, 'type' => $type, 'links' => array( |
43 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
43 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
44 | 44 | ) |
45 | - ) ); |
|
45 | + )); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -50,27 +50,27 @@ discard block |
||
50 | 50 | }; |
51 | 51 | |
52 | 52 | |
53 | -$fields = $this->param( 'fields', array() ); |
|
53 | +$fields = $this->param('fields', array()); |
|
54 | 54 | |
55 | -foreach( (array) $fields as $resource => $list ) { |
|
56 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
55 | +foreach ((array) $fields as $resource => $list) { |
|
56 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | -$data = $this->get( 'data', array() ); |
|
61 | -$childItems = $this->get( 'childItems', array() ); |
|
60 | +$data = $this->get('data', array()); |
|
61 | +$childItems = $this->get('childItems', array()); |
|
62 | 62 | |
63 | -if( is_array( $data ) ) |
|
63 | +if (is_array($data)) |
|
64 | 64 | { |
65 | 65 | $response = array(); |
66 | 66 | |
67 | - foreach( $data as $item ) { |
|
68 | - $response[] = $build( $this, $item, $fields, $childItems ); |
|
67 | + foreach ($data as $item) { |
|
68 | + $response[] = $build($this, $item, $fields, $childItems); |
|
69 | 69 | } |
70 | 70 | } |
71 | -elseif( $data !== null ) |
|
71 | +elseif ($data !== null) |
|
72 | 72 | { |
73 | - $response = $build( $this, $data, $fields, $childItems ); |
|
73 | + $response = $build($this, $data, $fields, $childItems); |
|
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
@@ -78,4 +78,4 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | -echo json_encode( $response, $options ); |
|
82 | 81 | \ No newline at end of file |
82 | +echo json_encode($response, $options); |
|
83 | 83 | \ No newline at end of file |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $item->getChildren() as $childItem ) |
|
35 | + foreach ($item->getChildren() as $childItem) |
|
36 | 36 | { |
37 | 37 | $type = $childItem->getResourceType(); |
38 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
38 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
39 | 39 | } |
40 | 40 | |
41 | - foreach( $listItems as $listId => $listItem ) |
|
41 | + foreach ($listItems as $listId => $listItem) |
|
42 | 42 | { |
43 | - if( $listItem->getParentId() == $id ) |
|
43 | + if ($listItem->getParentId() == $id) |
|
44 | 44 | { |
45 | 45 | $type = $listItem->getDomain(); |
46 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
46 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
47 | 47 | |
48 | - $result['relationships'][$type][] = array( 'data' => array( |
|
48 | + $result['relationships'][$type][] = array('data' => array( |
|
49 | 49 | 'id' => $listItem->getRefId(), 'type' => $type, |
50 | 50 | 'attributes' => $listItem->toArray(), 'links' => array( |
51 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
51 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
52 | 52 | ) |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -58,27 +58,27 @@ discard block |
||
58 | 58 | }; |
59 | 59 | |
60 | 60 | |
61 | -$fields = $this->param( 'fields', array() ); |
|
61 | +$fields = $this->param('fields', array()); |
|
62 | 62 | |
63 | -foreach( (array) $fields as $resource => $list ) { |
|
64 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
63 | +foreach ((array) $fields as $resource => $list) { |
|
64 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | -$data = $this->get( 'data', array() ); |
|
69 | -$listItems = $this->get( 'listItems', array() ); |
|
68 | +$data = $this->get('data', array()); |
|
69 | +$listItems = $this->get('listItems', array()); |
|
70 | 70 | |
71 | -if( is_array( $data ) ) |
|
71 | +if (is_array($data)) |
|
72 | 72 | { |
73 | 73 | $response = array(); |
74 | 74 | |
75 | - foreach( $data as $item ) { |
|
76 | - $response[] = $build( $this, $item, $fields, $listItems ); |
|
75 | + foreach ($data as $item) { |
|
76 | + $response[] = $build($this, $item, $fields, $listItems); |
|
77 | 77 | } |
78 | 78 | } |
79 | -elseif( $data !== null ) |
|
79 | +elseif ($data !== null) |
|
80 | 80 | { |
81 | - $response = $build( $this, $data, $fields, $listItems ); |
|
81 | + $response = $build($this, $data, $fields, $listItems); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
@@ -86,4 +86,4 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | -echo json_encode( $response, $options ); |
|
90 | 89 | \ No newline at end of file |
90 | +echo json_encode($response, $options); |
|
91 | 91 | \ No newline at end of file |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
109 | 109 | * @return string Content for response body |
110 | 110 | */ |
111 | - public function get( $body, array &$header, &$status ) |
|
111 | + public function get($body, array &$header, &$status) |
|
112 | 112 | { |
113 | 113 | /** admin/jsonadm/partials/catalog/template-data |
114 | 114 | * Relative path to the data partial template file for the catalog client |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @since 2016.07 |
126 | 126 | * @category Developer |
127 | 127 | */ |
128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
129 | 129 | |
130 | - return parent::get( $body, $header, $status ); |
|
130 | + return parent::get($body, $header, $status); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | * @param array $include List of resource types that should be fetched |
139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
140 | 140 | */ |
141 | - protected function getChildItems( array $items, array $include ) |
|
141 | + protected function getChildItems(array $items, array $include) |
|
142 | 142 | { |
143 | 143 | $list = array(); |
144 | 144 | |
145 | - if( in_array( 'catalog', $include ) ) |
|
145 | + if (in_array('catalog', $include)) |
|
146 | 146 | { |
147 | - foreach( $items as $item ) { |
|
148 | - $list = array_merge( $list, $item->getChildren() ); |
|
147 | + foreach ($items as $item) { |
|
148 | + $list = array_merge($list, $item->getChildren()); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -159,27 +159,27 @@ discard block |
||
159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
161 | 161 | */ |
162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
163 | 163 | { |
164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
167 | 167 | $total = 1; |
168 | 168 | |
169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
169 | + if (($id = $view->param('id')) == null) |
|
170 | 170 | { |
171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
172 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
173 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
172 | + $view->listItems = $this->getListItems($view->data, $include); |
|
173 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
178 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
179 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
177 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
178 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
179 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
180 | 180 | } |
181 | 181 | |
182 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
182 | + $view->refItems = $this->getRefItems($view->listItems); |
|
183 | 183 | $view->total = $total; |
184 | 184 | |
185 | 185 | return $view; |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | * @param array $include List of resource types that should be fetched |
194 | 194 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
195 | 195 | */ |
196 | - protected function getListItems( array $items, array $include ) |
|
196 | + protected function getListItems(array $items, array $include) |
|
197 | 197 | { |
198 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
198 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
199 | 199 | |
200 | 200 | $search = $manager->createSearch(); |
201 | 201 | $expr = array( |
202 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
203 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
202 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
203 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
204 | 204 | ); |
205 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
205 | + $search->setConditions($search->combine('&&', $expr)); |
|
206 | 206 | |
207 | - return $manager->searchItems( $search ); |
|
207 | + return $manager->searchItems($search); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -215,32 +215,32 @@ discard block |
||
215 | 215 | * @param \stdClass $entry Object including "id" and "attributes" elements |
216 | 216 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
217 | 217 | */ |
218 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
218 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
219 | 219 | { |
220 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
221 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
220 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
221 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
222 | 222 | |
223 | - if( isset( $entry->id ) ) |
|
223 | + if (isset($entry->id)) |
|
224 | 224 | { |
225 | - $item = $manager->getItem( $entry->id ); |
|
226 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
227 | - $manager->saveItem( $item ); |
|
225 | + $item = $manager->getItem($entry->id); |
|
226 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
227 | + $manager->saveItem($item); |
|
228 | 228 | |
229 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
230 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
229 | + if (isset($entry->parentid) && $targetId !== null) { |
|
230 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | 235 | $item = $manager->createItem(); |
236 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
237 | - $manager->insertItem( $item, $targetId, $refId ); |
|
236 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
237 | + $manager->insertItem($item, $targetId, $refId); |
|
238 | 238 | } |
239 | 239 | |
240 | - if( isset( $entry->relationships ) ) { |
|
241 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
240 | + if (isset($entry->relationships)) { |
|
241 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
242 | 242 | } |
243 | 243 | |
244 | - return $manager->getItem( $item->getId() ); |
|
244 | + return $manager->getItem($item->getId()); |
|
245 | 245 | } |
246 | 246 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,41 +27,41 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $item->getChildren() as $childItem ) |
|
35 | + foreach ($item->getChildren() as $childItem) |
|
36 | 36 | { |
37 | 37 | $type = $childItem->getResourceType(); |
38 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
38 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return $result; |
42 | 42 | }; |
43 | 43 | |
44 | 44 | |
45 | -$fields = $this->param( 'fields', array() ); |
|
45 | +$fields = $this->param('fields', array()); |
|
46 | 46 | |
47 | -foreach( (array) $fields as $resource => $list ) { |
|
48 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
47 | +foreach ((array) $fields as $resource => $list) { |
|
48 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | -$data = $this->get( 'data', array() ); |
|
52 | +$data = $this->get('data', array()); |
|
53 | 53 | |
54 | -if( is_array( $data ) ) |
|
54 | +if (is_array($data)) |
|
55 | 55 | { |
56 | 56 | $response = array(); |
57 | 57 | |
58 | - foreach( $data as $item ) { |
|
59 | - $response[] = $build( $this, $item, $fields ); |
|
58 | + foreach ($data as $item) { |
|
59 | + $response[] = $build($this, $item, $fields); |
|
60 | 60 | } |
61 | 61 | } |
62 | -elseif( $data !== null ) |
|
62 | +elseif ($data !== null) |
|
63 | 63 | { |
64 | - $response = $build( $this, $data, $fields ); |
|
64 | + $response = $build($this, $data, $fields); |
|
65 | 65 | } |
66 | 66 | else |
67 | 67 | { |
@@ -69,4 +69,4 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | -echo json_encode( $response, $options ); |
|
73 | 72 | \ No newline at end of file |
73 | +echo json_encode($response, $options); |
|
74 | 74 | \ No newline at end of file |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
109 | 109 | * @return string Content for response body |
110 | 110 | */ |
111 | - public function get( $body, array &$header, &$status ) |
|
111 | + public function get($body, array &$header, &$status) |
|
112 | 112 | { |
113 | 113 | /** admin/jsonadm/partials/locale/site/template-data |
114 | 114 | * Relative path to the data partial template file for the locale site client |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @since 2016.07 |
126 | 126 | * @category Developer |
127 | 127 | */ |
128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) ); |
|
128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data')); |
|
129 | 129 | |
130 | - return parent::get( $body, $header, $status ); |
|
130 | + return parent::get($body, $header, $status); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | * @param array $include List of resource types that should be fetched |
139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
140 | 140 | */ |
141 | - protected function getChildItems( array $items, array $include ) |
|
141 | + protected function getChildItems(array $items, array $include) |
|
142 | 142 | { |
143 | 143 | $list = array(); |
144 | 144 | |
145 | - if( in_array( 'locale/site', $include ) ) |
|
145 | + if (in_array('locale/site', $include)) |
|
146 | 146 | { |
147 | - foreach( $items as $item ) { |
|
148 | - $list = array_merge( $list, $item->getChildren() ); |
|
147 | + foreach ($items as $item) { |
|
148 | + $list = array_merge($list, $item->getChildren()); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
161 | 161 | */ |
162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
163 | 163 | { |
164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
167 | 167 | $total = 1; |
168 | 168 | |
169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
169 | + if (($id = $view->param('id')) == null) |
|
170 | 170 | { |
171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
172 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
172 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
173 | 173 | } |
174 | 174 | else |
175 | 175 | { |
176 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
177 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
176 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
177 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | $view->listItems = array(); |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | * @param \stdClass $entry Object including "id" and "attributes" elements |
193 | 193 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
194 | 194 | */ |
195 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
195 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
196 | 196 | { |
197 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
198 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
197 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
198 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
199 | 199 | |
200 | - if( isset( $entry->id ) ) |
|
200 | + if (isset($entry->id)) |
|
201 | 201 | { |
202 | - $item = $manager->getItem( $entry->id ); |
|
203 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
204 | - $manager->saveItem( $item ); |
|
202 | + $item = $manager->getItem($entry->id); |
|
203 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
204 | + $manager->saveItem($item); |
|
205 | 205 | |
206 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
207 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
206 | + if (isset($entry->parentid) && $targetId !== null) { |
|
207 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | else |
211 | 211 | { |
212 | 212 | $item = $manager->createItem(); |
213 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
214 | - $manager->insertItem( $item, $targetId, $refId ); |
|
213 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
214 | + $manager->insertItem($item, $targetId, $refId); |
|
215 | 215 | } |
216 | 216 | |
217 | - if( isset( $entry->relationships ) ) { |
|
218 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
217 | + if (isset($entry->relationships)) { |
|
218 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
219 | 219 | } |
220 | 220 | |
221 | - return $manager->getItem( $item->getId() ); |
|
221 | + return $manager->getItem($item->getId()); |
|
222 | 222 | } |
223 | 223 | } |
@@ -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,25 +30,25 @@ 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 | 40 | $header = array(); |
41 | 41 | $status = 500; |
42 | 42 | |
43 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
44 | 44 | |
45 | - $this->assertEquals( 200, $status ); |
|
46 | - $this->assertEquals( 1, count( $header ) ); |
|
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 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
45 | + $this->assertEquals(200, $status); |
|
46 | + $this->assertEquals(1, count($header)); |
|
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 | + $this->assertArrayNotHasKey('errors', $result); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -56,27 +56,27 @@ discard block |
||
56 | 56 | { |
57 | 57 | $params = array( |
58 | 58 | 'filter' => array( |
59 | - '==' => array( 'order.datepayment' => '2008-02-15 12:34:56' ) |
|
59 | + '==' => array('order.datepayment' => '2008-02-15 12:34:56') |
|
60 | 60 | ), |
61 | 61 | 'include' => 'order/base,order/status' |
62 | 62 | ); |
63 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
64 | - $this->view->addHelper( 'param', $helper ); |
|
63 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
64 | + $this->view->addHelper('param', $helper); |
|
65 | 65 | |
66 | 66 | $header = array(); |
67 | 67 | $status = 500; |
68 | 68 | |
69 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
70 | - |
|
71 | - $this->assertEquals( 200, $status ); |
|
72 | - $this->assertEquals( 1, count( $header ) ); |
|
73 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
74 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
75 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
76 | - $this->assertEquals( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
77 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base'] ) ); |
|
78 | - $this->assertEquals( 4, count( $result['included'] ) ); |
|
79 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
69 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
70 | + |
|
71 | + $this->assertEquals(200, $status); |
|
72 | + $this->assertEquals(1, count($header)); |
|
73 | + $this->assertEquals(1, $result['meta']['total']); |
|
74 | + $this->assertEquals(1, count($result['data'])); |
|
75 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
76 | + $this->assertEquals(3, count($result['data'][0]['relationships']['order/status'])); |
|
77 | + $this->assertEquals(1, count($result['data'][0]['relationships']['order/base'])); |
|
78 | + $this->assertEquals(4, count($result['included'])); |
|
79 | + $this->assertArrayNotHasKey('errors', $result); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -89,22 +89,22 @@ discard block |
||
89 | 89 | 'sort' => 'order.id', |
90 | 90 | 'include' => 'order/status' |
91 | 91 | ); |
92 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
93 | - $this->view->addHelper( 'param', $helper ); |
|
92 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
93 | + $this->view->addHelper('param', $helper); |
|
94 | 94 | |
95 | 95 | $header = array(); |
96 | 96 | $status = 500; |
97 | 97 | |
98 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
99 | - |
|
100 | - $this->assertEquals( 200, $status ); |
|
101 | - $this->assertEquals( 1, count( $header ) ); |
|
102 | - $this->assertGreaterThanOrEqual( 4, $result['meta']['total'] ); |
|
103 | - $this->assertGreaterThanOrEqual( 4, count( $result['data'] ) ); |
|
104 | - $this->assertEquals( 'order', $result['data'][0]['type'] ); |
|
105 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
106 | - $this->assertGreaterThanOrEqual( 3, count( $result['data'][0]['relationships']['order/status'] ) ); |
|
107 | - $this->assertGreaterThanOrEqual( 11, count( $result['included'] ) ); |
|
108 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
98 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
99 | + |
|
100 | + $this->assertEquals(200, $status); |
|
101 | + $this->assertEquals(1, count($header)); |
|
102 | + $this->assertGreaterThanOrEqual(4, $result['meta']['total']); |
|
103 | + $this->assertGreaterThanOrEqual(4, count($result['data'])); |
|
104 | + $this->assertEquals('order', $result['data'][0]['type']); |
|
105 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
106 | + $this->assertGreaterThanOrEqual(3, count($result['data'][0]['relationships']['order/status'])); |
|
107 | + $this->assertGreaterThanOrEqual(11, count($result['included'])); |
|
108 | + $this->assertArrayNotHasKey('errors', $result); |
|
109 | 109 | } |
110 | 110 | } |
@@ -29,39 +29,39 @@ discard block |
||
29 | 29 | * @param integer &$status Variable which contains the HTTP status afterwards |
30 | 30 | * @return string Content for response body |
31 | 31 | */ |
32 | - public function delete( $body, array &$header, &$status ) |
|
32 | + public function delete($body, array &$header, &$status) |
|
33 | 33 | { |
34 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
34 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
35 | 35 | $view = $this->getView(); |
36 | 36 | |
37 | 37 | try |
38 | 38 | { |
39 | - $view = $this->deleteItems( $view, $body ); |
|
39 | + $view = $this->deleteItems($view, $body); |
|
40 | 40 | $status = 200; |
41 | 41 | } |
42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
42 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
43 | 43 | { |
44 | 44 | $status = $e->getCode(); |
45 | - $view->errors = array( array( |
|
46 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
45 | + $view->errors = array(array( |
|
46 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
47 | 47 | 'detail' => $e->getTraceAsString(), |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | } |
50 | - catch( \Aimeos\MShop\Exception $e ) |
|
50 | + catch (\Aimeos\MShop\Exception $e) |
|
51 | 51 | { |
52 | 52 | $status = 404; |
53 | - $view->errors = array( array( |
|
54 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
53 | + $view->errors = array(array( |
|
54 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
55 | 55 | 'detail' => $e->getTraceAsString(), |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | } |
58 | - catch( \Exception $e ) |
|
58 | + catch (\Exception $e) |
|
59 | 59 | { |
60 | 60 | $status = 500; |
61 | - $view->errors = array( array( |
|
61 | + $view->errors = array(array( |
|
62 | 62 | 'title' => $e->getMessage(), |
63 | 63 | 'detail' => $e->getTraceAsString(), |
64 | - ) ); |
|
64 | + )); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** admin/jsonadm/standard/template-delete |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
93 | 93 | $default = 'delete-default.php'; |
94 | 94 | |
95 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
95 | + return $view->render($view->config($tplconf, $default)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,41 +104,41 @@ discard block |
||
104 | 104 | * @param integer &$status Variable which contains the HTTP status afterwards |
105 | 105 | * @return string Content for response body |
106 | 106 | */ |
107 | - public function get( $body, array &$header, &$status ) |
|
107 | + public function get($body, array &$header, &$status) |
|
108 | 108 | { |
109 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
109 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
110 | 110 | |
111 | 111 | $view = $this->getView(); |
112 | - $aggregate = $view->param( 'aggregate' ); |
|
112 | + $aggregate = $view->param('aggregate'); |
|
113 | 113 | |
114 | 114 | try |
115 | 115 | { |
116 | - if( $aggregate !== null ) { |
|
117 | - $view = $this->getAggregate( $view ); |
|
116 | + if ($aggregate !== null) { |
|
117 | + $view = $this->getAggregate($view); |
|
118 | 118 | } else { |
119 | - $view = $this->getItems( $view ); |
|
119 | + $view = $this->getItems($view); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $status = 200; |
123 | 123 | } |
124 | - catch( \Aimeos\MShop\Exception $e ) |
|
124 | + catch (\Aimeos\MShop\Exception $e) |
|
125 | 125 | { |
126 | 126 | $status = 404; |
127 | - $view->errors = array( array( |
|
128 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
127 | + $view->errors = array(array( |
|
128 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
129 | 129 | 'detail' => $e->getTraceAsString(), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | } |
132 | - catch( \Exception $e ) |
|
132 | + catch (\Exception $e) |
|
133 | 133 | { |
134 | 134 | $status = 500; |
135 | - $view->errors = array( array( |
|
135 | + $view->errors = array(array( |
|
136 | 136 | 'title' => $e->getMessage(), |
137 | 137 | 'detail' => $e->getTraceAsString(), |
138 | - ) ); |
|
138 | + )); |
|
139 | 139 | } |
140 | 140 | |
141 | - if( $aggregate !== null ) |
|
141 | + if ($aggregate !== null) |
|
142 | 142 | { |
143 | 143 | /** admin/jsonadm/standard/template-aggregate |
144 | 144 | * Relative path to the JSON API template for GET aggregate requests |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $default = 'get-default.php'; |
200 | 200 | } |
201 | 201 | |
202 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
202 | + return $view->render($view->config($tplconf, $default)); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -211,39 +211,39 @@ discard block |
||
211 | 211 | * @param integer &$status Variable which contains the HTTP status afterwards |
212 | 212 | * @return string Content for response body |
213 | 213 | */ |
214 | - public function patch( $body, array &$header, &$status ) |
|
214 | + public function patch($body, array &$header, &$status) |
|
215 | 215 | { |
216 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
216 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
217 | 217 | $view = $this->getView(); |
218 | 218 | |
219 | 219 | try |
220 | 220 | { |
221 | - $view = $this->patchItems( $view, $body, $header ); |
|
221 | + $view = $this->patchItems($view, $body, $header); |
|
222 | 222 | $status = 200; |
223 | 223 | } |
224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
224 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
225 | 225 | { |
226 | 226 | $status = $e->getCode(); |
227 | - $view->errors = array( array( |
|
228 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
227 | + $view->errors = array(array( |
|
228 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
229 | 229 | 'detail' => $e->getTraceAsString(), |
230 | - ) ); |
|
230 | + )); |
|
231 | 231 | } |
232 | - catch( \Aimeos\MShop\Exception $e ) |
|
232 | + catch (\Aimeos\MShop\Exception $e) |
|
233 | 233 | { |
234 | 234 | $status = 404; |
235 | - $view->errors = array( array( |
|
236 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
235 | + $view->errors = array(array( |
|
236 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
237 | 237 | 'detail' => $e->getTraceAsString(), |
238 | - ) ); |
|
238 | + )); |
|
239 | 239 | } |
240 | - catch( \Exception $e ) |
|
240 | + catch (\Exception $e) |
|
241 | 241 | { |
242 | 242 | $status = 500; |
243 | - $view->errors = array( array( |
|
243 | + $view->errors = array(array( |
|
244 | 244 | 'title' => $e->getMessage(), |
245 | 245 | 'detail' => $e->getTraceAsString(), |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** admin/jsonadm/standard/template-patch |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
275 | 275 | $default = 'patch-default.php'; |
276 | 276 | |
277 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
277 | + return $view->render($view->config($tplconf, $default)); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
@@ -286,39 +286,39 @@ discard block |
||
286 | 286 | * @param integer &$status Variable which contains the HTTP status afterwards |
287 | 287 | * @return string Content for response body |
288 | 288 | */ |
289 | - public function post( $body, array &$header, &$status ) |
|
289 | + public function post($body, array &$header, &$status) |
|
290 | 290 | { |
291 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
291 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
292 | 292 | $view = $this->getView(); |
293 | 293 | |
294 | 294 | try |
295 | 295 | { |
296 | - $view = $this->postItems( $view, $body, $header ); |
|
296 | + $view = $this->postItems($view, $body, $header); |
|
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,7 +349,7 @@ discard block |
||
349 | 349 | $tplconf = 'admin/jsonadm/standard/template-post'; |
350 | 350 | $default = 'post-default.php'; |
351 | 351 | |
352 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
352 | + return $view->render($view->config($tplconf, $default)); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -361,15 +361,15 @@ discard block |
||
361 | 361 | * @param integer &$status Variable which contains the HTTP status afterwards |
362 | 362 | * @return string Content for response body |
363 | 363 | */ |
364 | - public function put( $body, array &$header, &$status ) |
|
364 | + public function put($body, array &$header, &$status) |
|
365 | 365 | { |
366 | 366 | $status = 501; |
367 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
367 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
368 | 368 | $view = $this->getView(); |
369 | 369 | |
370 | - $view->errors = array( array( |
|
371 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
372 | - ) ); |
|
370 | + $view->errors = array(array( |
|
371 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
372 | + )); |
|
373 | 373 | |
374 | 374 | /** admin/jsonadm/standard/template-put |
375 | 375 | * Relative path to the JSON API template for PUT requests |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $tplconf = 'admin/jsonadm/standard/template-put'; |
400 | 400 | $default = 'put-default.php'; |
401 | 401 | |
402 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
402 | + return $view->render($view->config($tplconf, $default)); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @param integer &$status Variable which contains the HTTP status afterwards |
412 | 412 | * @return string Content for response body |
413 | 413 | */ |
414 | - public function options( $body, array &$header, &$status ) |
|
414 | + public function options($body, array &$header, &$status) |
|
415 | 415 | { |
416 | 416 | $context = $this->getContext(); |
417 | 417 | $view = $this->getView(); |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | { |
421 | 421 | $resources = $attributes = array(); |
422 | 422 | |
423 | - foreach( $this->getDomains( $view ) as $domain ) |
|
423 | + foreach ($this->getDomains($view) as $domain) |
|
424 | 424 | { |
425 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
426 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
427 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
425 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
426 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
427 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | $view->resources = $resources; |
@@ -436,21 +436,21 @@ discard block |
||
436 | 436 | ); |
437 | 437 | $status = 200; |
438 | 438 | } |
439 | - catch( \Aimeos\MShop\Exception $e ) |
|
439 | + catch (\Aimeos\MShop\Exception $e) |
|
440 | 440 | { |
441 | 441 | $status = 404; |
442 | - $view->errors = array( array( |
|
443 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
442 | + $view->errors = array(array( |
|
443 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
444 | 444 | 'detail' => $e->getTraceAsString(), |
445 | - ) ); |
|
445 | + )); |
|
446 | 446 | } |
447 | - catch( \Exception $e ) |
|
447 | + catch (\Exception $e) |
|
448 | 448 | { |
449 | 449 | $status = 500; |
450 | - $view->errors = array( array( |
|
450 | + $view->errors = array(array( |
|
451 | 451 | 'title' => $e->getMessage(), |
452 | 452 | 'detail' => $e->getTraceAsString(), |
453 | - ) ); |
|
453 | + )); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** admin/jsonadm/standard/template-options |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $tplconf = 'admin/jsonadm/standard/template-options'; |
482 | 482 | $default = 'options-default.php'; |
483 | 483 | |
484 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
484 | + return $view->render($view->config($tplconf, $default)); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -493,23 +493,23 @@ discard block |
||
493 | 493 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
494 | 494 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
495 | 495 | */ |
496 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
496 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
497 | 497 | { |
498 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
498 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
499 | 499 | |
500 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
500 | + if (($id = $view->param('id')) == null) |
|
501 | 501 | { |
502 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
503 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
502 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
503 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
504 | 504 | } |
505 | 505 | |
506 | - $ids = $this->getIds( $request ); |
|
507 | - $manager->deleteItems( $ids ); |
|
508 | - $view->total = count( $ids ); |
|
506 | + $ids = $this->getIds($request); |
|
507 | + $manager->deleteItems($ids); |
|
508 | + $view->total = count($ids); |
|
509 | 509 | } |
510 | 510 | else |
511 | 511 | { |
512 | - $manager->deleteItem( $id ); |
|
512 | + $manager->deleteItem($id); |
|
513 | 513 | $view->total = 1; |
514 | 514 | } |
515 | 515 | |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param \Aimeos\MW\View\Iface $view View instance |
524 | 524 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
525 | 525 | */ |
526 | - protected function getAggregate( \Aimeos\MW\View\Iface $view ) |
|
526 | + protected function getAggregate(\Aimeos\MW\View\Iface $view) |
|
527 | 527 | { |
528 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
528 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
529 | 529 | |
530 | - $key = $view->param( 'aggregate' ); |
|
530 | + $key = $view->param('aggregate'); |
|
531 | 531 | |
532 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
533 | - $view->data = $manager->aggregate( $search, $key ); |
|
532 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
533 | + $view->data = $manager->aggregate($search, $key); |
|
534 | 534 | |
535 | 535 | return $view; |
536 | 536 | } |
@@ -542,27 +542,27 @@ discard block |
||
542 | 542 | * @param \Aimeos\MW\View\Iface $view View instance |
543 | 543 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
544 | 544 | */ |
545 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
545 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
546 | 546 | { |
547 | 547 | $total = 1; |
548 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
549 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
548 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
549 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
550 | 550 | |
551 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
551 | + if (($id = $view->param('id')) == null) |
|
552 | 552 | { |
553 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
554 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
555 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
556 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
553 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
554 | + $view->data = $manager->searchItems($search, array(), $total); |
|
555 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
556 | + $view->listItems = $this->getListItems($view->data, $include); |
|
557 | 557 | } |
558 | 558 | else |
559 | 559 | { |
560 | - $view->data = $manager->getItem( $id, array() ); |
|
561 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
562 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
560 | + $view->data = $manager->getItem($id, array()); |
|
561 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
562 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
563 | 563 | } |
564 | 564 | |
565 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
565 | + $view->refItems = $this->getRefItems($view->listItems); |
|
566 | 566 | $view->total = $total; |
567 | 567 | |
568 | 568 | return $view; |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
577 | 577 | * @deprecated 2016.06 Use getItems() instead |
578 | 578 | */ |
579 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
579 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
580 | 580 | { |
581 | - return $this->getItems( $view ); |
|
581 | + return $this->getItems($view); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -590,33 +590,33 @@ discard block |
||
590 | 590 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
591 | 591 | * @return \Aimeos\MW\View\Iface Updated view instance |
592 | 592 | */ |
593 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
593 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
594 | 594 | { |
595 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
596 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
595 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
596 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
597 | 597 | } |
598 | 598 | |
599 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
599 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
600 | 600 | |
601 | - if( is_array( $request->data ) ) |
|
601 | + if (is_array($request->data)) |
|
602 | 602 | { |
603 | - $data = $this->saveData( $manager, $request ); |
|
603 | + $data = $this->saveData($manager, $request); |
|
604 | 604 | |
605 | 605 | $view->data = $data; |
606 | - $view->total = count( $data ); |
|
606 | + $view->total = count($data); |
|
607 | 607 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
608 | 608 | } |
609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
609 | + elseif (($id = $view->param('id')) != null) |
|
610 | 610 | { |
611 | 611 | $request->data->id = $id; |
612 | - $data = $this->saveEntry( $manager, $request->data ); |
|
612 | + $data = $this->saveEntry($manager, $request->data); |
|
613 | 613 | |
614 | 614 | $view->data = $data; |
615 | 615 | $view->total = 1; |
616 | 616 | } |
617 | 617 | else |
618 | 618 | { |
619 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
619 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | return $view; |
@@ -631,31 +631,31 @@ discard block |
||
631 | 631 | * @param array &$header Associative list of HTTP headers as value/result parameter |
632 | 632 | * @return \Aimeos\MW\View\Iface Updated view instance |
633 | 633 | */ |
634 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
634 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
635 | 635 | { |
636 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
637 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
636 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
637 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
638 | 638 | } |
639 | 639 | |
640 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
641 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
640 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
641 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
645 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
645 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
646 | 646 | |
647 | - if( is_array( $request->data ) ) |
|
647 | + if (is_array($request->data)) |
|
648 | 648 | { |
649 | - $data = $this->saveData( $manager, $request ); |
|
649 | + $data = $this->saveData($manager, $request); |
|
650 | 650 | |
651 | 651 | $view->data = $data; |
652 | - $view->total = count( $data ); |
|
652 | + $view->total = count($data); |
|
653 | 653 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
654 | 654 | } |
655 | 655 | else |
656 | 656 | { |
657 | 657 | $request->data->id = null; |
658 | - $data = $this->saveEntry( $manager, $request->data ); |
|
658 | + $data = $this->saveEntry($manager, $request->data); |
|
659 | 659 | |
660 | 660 | $view->data = $data; |
661 | 661 | $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 | } |