@@ -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\Coupon\Config\Standard( $this->context, $this->view, $templatePaths, 'coupon/config' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Config\Standard($this->context, $this->view, $templatePaths, 'coupon/config'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | $params = array( |
32 | 32 | 'id' => 'Example,Required,BasketValues', |
33 | 33 | ); |
34 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
35 | - $this->view->addHelper( 'param', $helper ); |
|
34 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
35 | + $this->view->addHelper('param', $helper); |
|
36 | 36 | |
37 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
38 | - $result = json_decode( (string) $response->getBody(), true ); |
|
37 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
38 | + $result = json_decode((string) $response->getBody(), true); |
|
39 | 39 | |
40 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
41 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
40 | + $this->assertEquals(200, $response->getStatusCode()); |
|
41 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
42 | 42 | |
43 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
44 | - $this->assertInternalType( 'array', $result['data'] ); |
|
45 | - $this->assertEquals( 'basketvalues.total-value-min', $result['data'][0]['id'] ); |
|
46 | - $this->assertEquals( 'basketvalues.total-value-max', $result['data'][1]['id'] ); |
|
43 | + $this->assertEquals(2, $result['meta']['total']); |
|
44 | + $this->assertInternalType('array', $result['data']); |
|
45 | + $this->assertEquals('basketvalues.total-value-min', $result['data'][0]['id']); |
|
46 | + $this->assertEquals('basketvalues.total-value-max', $result['data'][1]['id']); |
|
47 | 47 | |
48 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
48 | + $this->assertArrayNotHasKey('errors', $result); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | ?> |
12 | 12 | { |
13 | 13 | "meta": { |
14 | - "total": <?= $this->get( 'total', 0 ); ?> |
|
14 | + "total": <?= $this->get('total', 0); ?> |
|
15 | 15 | |
16 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
16 | + <?php if ($this->csrf()->name() != '') : ?> |
|
17 | 17 | , "csrf": { |
18 | 18 | "name": "<?= $this->csrf()->name(); ?>", |
19 | 19 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | } |
24 | 24 | |
25 | - <?php if( isset( $this->errors ) ) : ?> |
|
25 | + <?php if (isset($this->errors)) : ?> |
|
26 | 26 | |
27 | - ,"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
27 | + ,"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
28 | 28 | |
29 | 29 | <?php endif; ?> |
30 | 30 |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | ?> |
12 | 12 | { |
13 | 13 | "meta": { |
14 | - "total": <?= $this->get( 'total', 0 ); ?> |
|
14 | + "total": <?= $this->get('total', 0); ?> |
|
15 | 15 | |
16 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
16 | + <?php if ($this->csrf()->name() != '') : ?> |
|
17 | 17 | , "csrf": { |
18 | 18 | "name": "<?= $this->csrf()->name(); ?>", |
19 | 19 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | } |
24 | 24 | |
25 | - <?php if( isset( $this->errors ) ) : ?> |
|
25 | + <?php if (isset($this->errors)) : ?> |
|
26 | 26 | |
27 | - , "errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
27 | + , "errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
28 | 28 | |
29 | - <?php elseif( isset( $this->data ) ) : ?> |
|
29 | + <?php elseif (isset($this->data)) : ?> |
|
30 | 30 | |
31 | - , "data": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?> |
|
31 | + , "data": <?= $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?> |
|
32 | 32 | |
33 | 33 | <?php endif; ?> |
34 | 34 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @see admin/jsonadm/url/action |
23 | 23 | * @see admin/jsonadm/url/config |
24 | 24 | */ |
25 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
25 | +$target = $this->config('admin/jsonadm/url/target'); |
|
26 | 26 | |
27 | 27 | /** admin/jsonadm/url/controller |
28 | 28 | * Name of the client whose action should be called |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @see admin/jsonadm/url/action |
39 | 39 | * @see admin/jsonadm/url/config |
40 | 40 | */ |
41 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
41 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
42 | 42 | |
43 | 43 | /** admin/jsonadm/url/action |
44 | 44 | * Name of the action that should create the output |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @see admin/jsonadm/url/controller |
55 | 55 | * @see admin/jsonadm/url/config |
56 | 56 | */ |
57 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
57 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
58 | 58 | |
59 | 59 | /** admin/jsonadm/url/config |
60 | 60 | * Associative list of configuration options used for generating the URL |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @see admin/jsonadm/url/controller |
77 | 77 | * @see admin/jsonadm/url/action |
78 | 78 | */ |
79 | -$config = $this->config( 'admin/jsonadm/url/config', [] ); |
|
79 | +$config = $this->config('admin/jsonadm/url/config', []); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | /** admin/jsonadm/partials/template-errors |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | */ |
129 | 129 | |
130 | 130 | |
131 | -$total = $this->get( 'total', 0 ); |
|
132 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
133 | -$limit = max( $this->param( 'page/limit', 25 ), 1 ); |
|
131 | +$total = $this->get('total', 0); |
|
132 | +$offset = max($this->param('page/offset', 0), 0); |
|
133 | +$limit = max($this->param('page/limit', 25), 1); |
|
134 | 134 | |
135 | -$first = ( $offset > 0 ? 0 : null ); |
|
136 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
137 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
138 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
135 | +$first = ($offset > 0 ? 0 : null); |
|
136 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
137 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
138 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
139 | 139 | |
140 | 140 | |
141 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
142 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ) + ['id' => '']; |
|
143 | -$fields = $this->param( 'fields', [] ); |
|
141 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
142 | +$params = array_intersect_key($this->param(), array_flip($ref)) + ['id' => '']; |
|
143 | +$fields = $this->param('fields', []); |
|
144 | 144 | |
145 | -foreach( (array) $fields as $resource => $list ) { |
|
146 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
145 | +foreach ((array) $fields as $resource => $list) { |
|
146 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | "meta": { |
153 | 153 | "total": <?= $total; ?> |
154 | 154 | |
155 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
155 | + <?php if ($this->csrf()->name() != '') : ?> |
|
156 | 156 | , "csrf": { |
157 | 157 | "name": "<?= $this->csrf()->name(); ?>", |
158 | 158 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -163,42 +163,42 @@ discard block |
||
163 | 163 | |
164 | 164 | "links": { |
165 | 165 | |
166 | - <?php if( is_array( $this->get( 'data' ) ) ) : ?> |
|
166 | + <?php if (is_array($this->get('data'))) : ?> |
|
167 | 167 | |
168 | - <?php if( $first !== null ) : ?> |
|
168 | + <?php if ($first !== null) : ?> |
|
169 | 169 | |
170 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
170 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
171 | 171 | |
172 | 172 | <?php endif; ?> |
173 | - <?php if( $prev !== null ) : ?> |
|
173 | + <?php if ($prev !== null) : ?> |
|
174 | 174 | |
175 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
175 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
176 | 176 | |
177 | 177 | <?php endif; ?> |
178 | - <?php if( $next !== null ) : ?> |
|
178 | + <?php if ($next !== null) : ?> |
|
179 | 179 | |
180 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
180 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
181 | 181 | |
182 | 182 | <?php endif; ?> |
183 | - <?php if( $last !== null ) : ?> |
|
183 | + <?php if ($last !== null) : ?> |
|
184 | 184 | |
185 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
185 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
186 | 186 | |
187 | 187 | <?php endif; ?> |
188 | 188 | <?php endif; ?> |
189 | 189 | |
190 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>" |
|
190 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, [], $config); ?>" |
|
191 | 191 | }, |
192 | 192 | |
193 | - <?php if( isset( $this->errors ) ) : ?> |
|
193 | + <?php if (isset($this->errors)) : ?> |
|
194 | 194 | |
195 | - "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
195 | + "errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
196 | 196 | |
197 | - <?php elseif( isset( $this->data ) ) : ?> |
|
197 | + <?php elseif (isset($this->data)) : ?> |
|
198 | 198 | |
199 | - "data": <?= $this->partial( $this->config( $this->get( 'partial-data', 'admin/jsonadm/partials/template-data' ), 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ), 'childItems' => $this->get( 'childItems', [] ), 'listItems' => $this->get( 'listItems', [] ) ) ); ?>, |
|
199 | + "data": <?= $this->partial($this->config($this->get('partial-data', 'admin/jsonadm/partials/template-data'), 'partials/data-standard.php'), array('data' => $this->get('data'), 'childItems' => $this->get('childItems', []), 'listItems' => $this->get('listItems', []))); ?>, |
|
200 | 200 | |
201 | - "included": <?= $this->partial( $this->config( $this->get( 'partial-included', 'admin/jsonadm/partials/template-included' ), 'partials/included-standard.php' ), array( 'childItems' => $this->get( 'childItems', [] ), 'refItems' => $this->get( 'refItems', [] ) ) ); ?> |
|
201 | + "included": <?= $this->partial($this->config($this->get('partial-included', 'admin/jsonadm/partials/template-included'), 'partials/included-standard.php'), array('childItems' => $this->get('childItems', []), 'refItems' => $this->get('refItems', []))); ?> |
|
202 | 202 | |
203 | 203 | <?php endif; ?> |
204 | 204 |
@@ -8,19 +8,19 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -$data = $this->get( 'data', [] ); |
|
11 | +$data = $this->get('data', []); |
|
12 | 12 | $entries = []; |
13 | 13 | |
14 | -foreach( $data as $key => $value ) { |
|
15 | - $entries[] = array( 'id' => $key, 'type' => 'aggregate', 'attributes' => $value ); |
|
14 | +foreach ($data as $key => $value) { |
|
15 | + $entries[] = array('id' => $key, 'type' => 'aggregate', 'attributes' => $value); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | { |
20 | 20 | "meta": { |
21 | - "total": <?= count( $data ); ?> |
|
21 | + "total": <?= count($data); ?> |
|
22 | 22 | |
23 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
23 | + <?php if ($this->csrf()->name() != '') : ?> |
|
24 | 24 | , "csrf": { |
25 | 25 | "name": "<?= $this->csrf()->name(); ?>", |
26 | 26 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | }, |
31 | 31 | |
32 | - <?php if( isset( $this->errors ) ) : ?> |
|
32 | + <?php if (isset($this->errors)) : ?> |
|
33 | 33 | |
34 | - "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
34 | + "errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
35 | 35 | |
36 | - <?php elseif( isset( $this->data ) ) : ?> |
|
36 | + <?php elseif (isset($this->data)) : ?> |
|
37 | 37 | |
38 | - "data": <?= json_encode( $entries ); ?> |
|
38 | + "data": <?= json_encode($entries); ?> |
|
39 | 39 | |
40 | 40 | <?php endif; ?> |
41 | 41 | } |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | ?> |
12 | 12 | { |
13 | 13 | "meta": { |
14 | - "total": <?= $this->get( 'total', 0 ); ?> |
|
14 | + "total": <?= $this->get('total', 0); ?> |
|
15 | 15 | |
16 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
16 | + <?php if ($this->csrf()->name() != '') : ?> |
|
17 | 17 | , "csrf": { |
18 | 18 | "name": "<?= $this->csrf()->name(); ?>", |
19 | 19 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | } |
24 | 24 | |
25 | - <?php if( isset( $this->errors ) ) : ?> |
|
25 | + <?php if (isset($this->errors)) : ?> |
|
26 | 26 | |
27 | - , "errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
27 | + , "errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
28 | 28 | |
29 | - <?php elseif( isset( $this->data ) ) : ?> |
|
29 | + <?php elseif (isset($this->data)) : ?> |
|
30 | 30 | |
31 | - , "data": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?> |
|
31 | + , "data": <?= $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?> |
|
32 | 32 | |
33 | 33 | <?php endif; ?> |
34 | 34 |
@@ -9,29 +9,29 @@ discard block |
||
9 | 9 | |
10 | 10 | |
11 | 11 | $options = 0; |
12 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
12 | +if (defined('JSON_PRETTY_PRINT')) { |
|
13 | 13 | $options = JSON_PRETTY_PRINT; |
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | -$fields = $this->param( 'fields', [] ); |
|
17 | +$fields = $this->param('fields', []); |
|
18 | 18 | |
19 | -foreach( (array) $fields as $resource => $list ) { |
|
20 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
19 | +foreach ((array) $fields as $resource => $list) { |
|
20 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
24 | -$build = function( array $attrItems, $id ) use ( $fields ) |
|
24 | +$build = function(array $attrItems, $id) use ($fields) |
|
25 | 25 | { |
26 | 26 | $result = []; |
27 | 27 | $type = 'criteria/attribute'; |
28 | 28 | |
29 | - foreach( $attrItems as $attrItem ) |
|
29 | + foreach ($attrItems as $attrItem) |
|
30 | 30 | { |
31 | - $attributes = $attrItem->toArray( true ); |
|
31 | + $attributes = $attrItem->toArray(true); |
|
32 | 32 | |
33 | - if( isset( $fields[$type] ) ) { |
|
34 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
33 | + if (isset($fields[$type])) { |
|
34 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $result[] = array( |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | |
48 | -$configItems = $this->get( 'configItems', [] ); |
|
48 | +$configItems = $this->get('configItems', []); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | ?> |
52 | 52 | { |
53 | 53 | "meta": { |
54 | - "total": <?= count( $configItems ); ?> |
|
54 | + "total": <?= count($configItems); ?> |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | |
58 | - <?php if( isset( $this->errors ) ) : ?> |
|
58 | + <?php if (isset($this->errors)) : ?> |
|
59 | 59 | |
60 | - , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
60 | + , "errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
61 | 61 | |
62 | 62 | <?php else : ?> |
63 | 63 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
64 | + , "data": <?= json_encode($build($configItems, $this->param('id')), $options); ?> |
|
65 | 65 | |
66 | 66 | <?php endif; ?> |
67 | 67 | } |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | $view = $this->getView(); |
116 | 116 | |
117 | 117 | try |
118 | 118 | { |
119 | - $response = $this->getItems( $view, $request, $response ); |
|
119 | + $response = $this->getItems($view, $request, $response); |
|
120 | 120 | $status = 200; |
121 | 121 | } |
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
122 | + catch (\Aimeos\MShop\Exception $e) |
|
123 | 123 | { |
124 | 124 | $status = 404; |
125 | - $view->errors = array( array( |
|
126 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
125 | + $view->errors = array(array( |
|
126 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
127 | 127 | 'detail' => $e->getTraceAsString(), |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | - catch( \Exception $e ) |
|
130 | + catch (\Exception $e) |
|
131 | 131 | { |
132 | 132 | $status = 500; |
133 | - $view->errors = array( array( |
|
133 | + $view->errors = array(array( |
|
134 | 134 | 'title' => $e->getMessage(), |
135 | 135 | 'detail' => $e->getTraceAsString(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** admin/jsonadm/coupon/config/template-get |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $tplconf = 'admin/jsonadm/coupon/config/template-get'; |
159 | 159 | $default = 'config-default.php'; |
160 | 160 | |
161 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
161 | + $body = $view->render($view->config($tplconf, $default)); |
|
162 | 162 | |
163 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
164 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
165 | - ->withStatus( $status ); |
|
163 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
164 | + ->withBody($view->response()->createStreamFromString($body)) |
|
165 | + ->withStatus($status); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
175 | 175 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
176 | 176 | */ |
177 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
177 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
178 | 178 | { |
179 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
180 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
179 | + if (($id = $view->param('id')) == null) { |
|
180 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
181 | 181 | } |
182 | 182 | |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
184 | 184 | |
185 | 185 | $item = $manager->createItem(); |
186 | - $item->setProvider( $id ); |
|
186 | + $item->setProvider($id); |
|
187 | 187 | |
188 | - $view->configItems = $manager->getProvider( $item, null )->getConfigBE(); |
|
188 | + $view->configItems = $manager->getProvider($item, null)->getConfigBE(); |
|
189 | 189 | |
190 | 190 | return $response; |
191 | 191 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
37 | 37 | { |
38 | 38 | $this->view = $view; |
39 | 39 | $this->context = $context; |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param array $param List of method parameter |
50 | 50 | * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
51 | 51 | */ |
52 | - public function __call( $name, array $param ) |
|
52 | + public function __call($name, array $param) |
|
53 | 53 | { |
54 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
54 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param array $include List of resource types that should be fetched |
63 | 63 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
64 | 64 | */ |
65 | - protected function getChildItems( array $items, array $include ) |
|
65 | + protected function getChildItems(array $items, array $include) |
|
66 | 66 | { |
67 | 67 | return []; |
68 | 68 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
86 | 86 | * @return array List of domain names |
87 | 87 | */ |
88 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
88 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
89 | 89 | { |
90 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
90 | + if (($domains = $view->param('resource')) == '') |
|
91 | 91 | { |
92 | 92 | /** admin/jsonadm/domains |
93 | 93 | * A list of domain names whose clients are available for the JSON API |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order', |
111 | 111 | 'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text' |
112 | 112 | ); |
113 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
113 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return (array) $domains; |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @param \stdClass $request Decoded request body |
124 | 124 | * @return array List of item IDs |
125 | 125 | */ |
126 | - protected function getIds( $request ) |
|
126 | + protected function getIds($request) |
|
127 | 127 | { |
128 | 128 | $ids = []; |
129 | 129 | |
130 | - if( isset( $request->data ) ) |
|
130 | + if (isset($request->data)) |
|
131 | 131 | { |
132 | - foreach( (array) $request->data as $entry ) |
|
132 | + foreach ((array) $request->data as $entry) |
|
133 | 133 | { |
134 | - if( isset( $entry->id ) ) { |
|
134 | + if (isset($entry->id)) { |
|
135 | 135 | $ids[] = $entry->id; |
136 | 136 | } |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param array $include List of resource types that should be fetched |
149 | 149 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
150 | 150 | */ |
151 | - protected function getListItems( array $items, array $include ) |
|
151 | + protected function getListItems(array $items, array $include) |
|
152 | 152 | { |
153 | 153 | return []; |
154 | 154 | } |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
172 | 172 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
173 | 173 | */ |
174 | - protected function getRefItems( array $listItems ) |
|
174 | + protected function getRefItems(array $listItems) |
|
175 | 175 | { |
176 | 176 | $list = $map = []; |
177 | 177 | $context = $this->getContext(); |
178 | 178 | |
179 | - foreach( $listItems as $listItem ) { |
|
179 | + foreach ($listItems as $listItem) { |
|
180 | 180 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
181 | 181 | } |
182 | 182 | |
183 | - foreach( $map as $domain => $ids ) |
|
183 | + foreach ($map as $domain => $ids) |
|
184 | 184 | { |
185 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
185 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
186 | 186 | |
187 | 187 | $search = $manager->createSearch(); |
188 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
188 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
189 | 189 | |
190 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
190 | + $list = array_merge($list, $manager->searchItems($search)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return $list; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
201 | 201 | * @return array List of domain names |
202 | 202 | */ |
203 | - protected function getResources( \Aimeos\MW\View\Iface $view ) |
|
203 | + protected function getResources(\Aimeos\MW\View\Iface $view) |
|
204 | 204 | { |
205 | 205 | /** admin/jsonadm/resources |
206 | 206 | * A list of additional resources name whose clients are available for the JSON API |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @category Developer |
219 | 219 | * @see admin/jsonadm/domains |
220 | 220 | */ |
221 | - return (array) $view->config( 'admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config'] ); |
|
221 | + return (array) $view->config('admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config']); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | * @param array $params List of criteria data with condition, sorting and paging |
252 | 252 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
253 | 253 | */ |
254 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
254 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
255 | 255 | { |
256 | - $this->initCriteriaConditions( $criteria, $params ); |
|
257 | - $this->initCriteriaSortations( $criteria, $params ); |
|
258 | - $this->initCriteriaSlice( $criteria, $params ); |
|
256 | + $this->initCriteriaConditions($criteria, $params); |
|
257 | + $this->initCriteriaSortations($criteria, $params); |
|
258 | + $this->initCriteriaSlice($criteria, $params); |
|
259 | 259 | |
260 | 260 | return $criteria; |
261 | 261 | } |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
268 | 268 | * @param array $params List of criteria data with condition, sorting and paging |
269 | 269 | */ |
270 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
270 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
271 | 271 | { |
272 | - if( !isset( $params['filter'] ) ) { |
|
272 | + if (!isset($params['filter'])) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | $existing = $criteria->getConditions(); |
277 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
277 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
278 | 278 | |
279 | - $expr = array( $criteria->getConditions(), $existing ); |
|
280 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
279 | + $expr = array($criteria->getConditions(), $existing); |
|
280 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
288 | 288 | * @param array $params List of criteria data with condition, sorting and paging |
289 | 289 | */ |
290 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
290 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
291 | 291 | { |
292 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
293 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
292 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
293 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
294 | 294 | |
295 | - $criteria->setSlice( $start, $size ); |
|
295 | + $criteria->setSlice($start, $size); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -302,24 +302,24 @@ discard block |
||
302 | 302 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
303 | 303 | * @param array $params List of criteria data with condition, sorting and paging |
304 | 304 | */ |
305 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
305 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
306 | 306 | { |
307 | - if( !isset( $params['sort'] ) ) { |
|
307 | + if (!isset($params['sort'])) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
311 | 311 | $sortation = []; |
312 | 312 | |
313 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
313 | + foreach (explode(',', $params['sort']) as $sort) |
|
314 | 314 | { |
315 | - if( $sort[0] === '-' ) { |
|
316 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
315 | + if ($sort[0] === '-') { |
|
316 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
317 | 317 | } else { |
318 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
318 | + $sortation[] = $criteria->sort('+', $sort); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - $criteria->setSortations( $sortation ); |
|
322 | + $criteria->setSortations($sortation); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param \stdClass $request Object with request body data |
331 | 331 | * @return array List of items |
332 | 332 | */ |
333 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
333 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
334 | 334 | { |
335 | 335 | $data = []; |
336 | 336 | |
337 | - if( isset( $request->data ) ) |
|
337 | + if (isset($request->data)) |
|
338 | 338 | { |
339 | - foreach( (array) $request->data as $entry ) { |
|
340 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
339 | + foreach ((array) $request->data as $entry) { |
|
340 | + $data[] = $this->saveEntry($manager, $entry); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | * @param \stdClass $entry Object including "id" and "attributes" elements |
353 | 353 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
354 | 354 | */ |
355 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
355 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
356 | 356 | { |
357 | - if( isset( $entry->id ) ) { |
|
358 | - $item = $manager->getItem( $entry->id ); |
|
357 | + if (isset($entry->id)) { |
|
358 | + $item = $manager->getItem($entry->id); |
|
359 | 359 | } else { |
360 | 360 | $item = $manager->createItem(); |
361 | 361 | } |
362 | 362 | |
363 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
364 | - $item = $manager->saveItem( $item ); |
|
363 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
364 | + $item = $manager->saveItem($item); |
|
365 | 365 | |
366 | - if( isset( $entry->relationships ) ) { |
|
367 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
366 | + if (isset($entry->relationships)) { |
|
367 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
368 | 368 | } |
369 | 369 | |
370 | - return $manager->getItem( $item->getId() ); |
|
370 | + return $manager->getItem($item->getId()); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -378,28 +378,28 @@ discard block |
||
378 | 378 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
379 | 379 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
380 | 380 | */ |
381 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
382 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
381 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
382 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
383 | 383 | { |
384 | 384 | $id = $item->getId(); |
385 | - $listManager = $manager->getSubManager( 'lists' ); |
|
385 | + $listManager = $manager->getSubManager('lists'); |
|
386 | 386 | |
387 | - foreach( (array) $relationships as $domain => $list ) |
|
387 | + foreach ((array) $relationships as $domain => $list) |
|
388 | 388 | { |
389 | - if( isset( $list->data ) ) |
|
389 | + if (isset($list->data)) |
|
390 | 390 | { |
391 | - foreach( (array) $list->data as $data ) |
|
391 | + foreach ((array) $list->data as $data) |
|
392 | 392 | { |
393 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
393 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
394 | 394 | |
395 | - if( isset( $data->id ) ) { |
|
396 | - $listItem->setRefId( $data->id ); |
|
395 | + if (isset($data->id)) { |
|
396 | + $listItem->setRefId($data->id); |
|
397 | 397 | } |
398 | 398 | |
399 | - $listItem->setParentId( $id ); |
|
400 | - $listItem->setDomain( $domain ); |
|
399 | + $listItem->setParentId($id); |
|
400 | + $listItem->setDomain($domain); |
|
401 | 401 | |
402 | - $listManager->saveItem( $listItem, false ); |
|
402 | + $listManager->saveItem($listItem, false); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
@@ -416,20 +416,20 @@ discard block |
||
416 | 416 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
417 | 417 | */ |
418 | 418 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
419 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
419 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
420 | 420 | { |
421 | - if( isset( $data->attributes ) ) |
|
421 | + if (isset($data->attributes)) |
|
422 | 422 | { |
423 | 423 | $attr = (array) $data->attributes; |
424 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
424 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
425 | 425 | |
426 | - if( isset( $attr[$key.'.type'] ) ) |
|
426 | + if (isset($attr[$key . '.type'])) |
|
427 | 427 | { |
428 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], [], $domain ); |
|
429 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
428 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], [], $domain); |
|
429 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
430 | 430 | } |
431 | 431 | |
432 | - $item->fromArray( $attr ); |
|
432 | + $item->fromArray($attr); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | return $item; |