@@ -8,45 +8,45 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
12 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
13 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
14 | -$config = $this->config( 'client/jsonapi/url/config', array() ); |
|
11 | +$target = $this->config('client/jsonapi/url/target'); |
|
12 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
13 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
14 | +$config = $this->config('client/jsonapi/url/config', array()); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | $view = $this; |
18 | 18 | $enc = $this->encoder(); |
19 | 19 | |
20 | 20 | |
21 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
22 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
21 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
22 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
23 | 23 | |
24 | 24 | |
25 | -$total = $this->get( 'total', 0 ); |
|
26 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
27 | -$limit = max( $this->param( 'page/limit', 100 ), 1 ); |
|
25 | +$total = $this->get('total', 0); |
|
26 | +$offset = max($this->param('page/offset', 0), 0); |
|
27 | +$limit = max($this->param('page/limit', 100), 1); |
|
28 | 28 | |
29 | -$first = ( $offset > 0 ? 0 : null ); |
|
30 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
31 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
32 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
29 | +$first = ($offset > 0 ? 0 : null); |
|
30 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
31 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
32 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
33 | 33 | |
34 | 34 | |
35 | -$fields = $this->param( 'fields', array() ); |
|
35 | +$fields = $this->param('fields', array()); |
|
36 | 36 | |
37 | -foreach( (array) $fields as $resource => $list ) { |
|
38 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
37 | +foreach ((array) $fields as $resource => $list) { |
|
38 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | -$entryFcn = function( \Aimeos\MShop\Common\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config ) |
|
42 | +$entryFcn = function(\Aimeos\MShop\Common\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config) |
|
43 | 43 | { |
44 | 44 | $attributes = $item->toArray(); |
45 | 45 | $type = $item->getResourceType(); |
46 | - $params = array( 'resource' => $type, 'id' => $item->getId() ); |
|
46 | + $params = array('resource' => $type, 'id' => $item->getId()); |
|
47 | 47 | |
48 | - if( isset( $fields[$type] ) ) { |
|
49 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
48 | + if (isset($fields[$type])) { |
|
49 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $entry = array( |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | 'type' => $item->getResourceType(), |
55 | 55 | 'links' => array( |
56 | 56 | 'self' => array( |
57 | - 'href' => $view->url( $target, $cntl, $action, $params, array(), $config ), |
|
58 | - 'allow' => array( 'GET' ), |
|
57 | + 'href' => $view->url($target, $cntl, $action, $params, array(), $config), |
|
58 | + 'allow' => array('GET'), |
|
59 | 59 | ), |
60 | 60 | ), |
61 | 61 | 'attributes' => $attributes, |
62 | 62 | ); |
63 | 63 | |
64 | - if( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface ) |
|
64 | + if ($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface) |
|
65 | 65 | { |
66 | - foreach( $item->getListItems() as $listItem ) |
|
66 | + foreach ($item->getListItems() as $listItem) |
|
67 | 67 | { |
68 | 68 | $domain = $listItem->getDomain(); |
69 | 69 | |
70 | - if( in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
71 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
70 | + if (in_array($domain, array('media', 'price', 'text'), true) |
|
71 | + && ($refItem = $listItem->getRefItem()) !== null |
|
72 | 72 | ) { |
73 | 73 | $entry['attributes'][$domain][] = $refItem->toArray() + $listItem->toArray(); |
74 | 74 | } |
75 | 75 | |
76 | - if( !in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
77 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
76 | + if (!in_array($domain, array('media', 'price', 'text'), true) |
|
77 | + && ($refItem = $listItem->getRefItem()) !== null |
|
78 | 78 | ) { |
79 | - $basic = array( 'id' => $refItem->getId(), 'type' => $domain ); |
|
79 | + $basic = array('id' => $refItem->getId(), 'type' => $domain); |
|
80 | 80 | $entry['relationships'][$domain]['data'][] = $basic + $listItem->toArray(); |
81 | 81 | } |
82 | 82 | } |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | }; |
87 | 87 | |
88 | 88 | |
89 | -$refFcn = function( \Aimeos\MShop\Common\Item\Iface $item, $level ) use ( $entryFcn, &$refFcn ) |
|
89 | +$refFcn = function(\Aimeos\MShop\Common\Item\Iface $item, $level) use ($entryFcn, &$refFcn) |
|
90 | 90 | { |
91 | 91 | $list = array(); |
92 | 92 | |
93 | - if( !( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface ) || $level > 1 ) { |
|
93 | + if (!($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface) || $level > 1) { |
|
94 | 94 | return $list; |
95 | 95 | } |
96 | 96 | |
97 | - foreach( $item->getListItems() as $listItem ) |
|
97 | + foreach ($item->getListItems() as $listItem) |
|
98 | 98 | { |
99 | 99 | $domain = $listItem->getDomain(); |
100 | 100 | |
101 | - if( !in_array( $domain, array( 'media', 'price', 'text' ), true ) |
|
102 | - && ( $refItem = $listItem->getRefItem() ) !== null |
|
101 | + if (!in_array($domain, array('media', 'price', 'text'), true) |
|
102 | + && ($refItem = $listItem->getRefItem()) !== null |
|
103 | 103 | ) { |
104 | - $list[] = $entryFcn( $refItem ); |
|
105 | - $list = array_merge( $list, $refFcn( $refItem, ++$level ) ); |
|
104 | + $list[] = $entryFcn($refItem); |
|
105 | + $list = array_merge($list, $refFcn($refItem, ++$level)); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -118,51 +118,51 @@ discard block |
||
118 | 118 | }, |
119 | 119 | |
120 | 120 | "links": { |
121 | - <?php if( is_array( $this->get( 'items' ) ) ) : ?> |
|
122 | - <?php if( $first !== null ) : ?> |
|
123 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
121 | + <?php if (is_array($this->get('items'))) : ?> |
|
122 | + <?php if ($first !== null) : ?> |
|
123 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
124 | 124 | <?php endif; ?> |
125 | - <?php if( $prev !== null ) : ?> |
|
126 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
125 | + <?php if ($prev !== null) : ?> |
|
126 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
127 | 127 | <?php endif; ?> |
128 | - <?php if( $next !== null ) : ?> |
|
129 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
128 | + <?php if ($next !== null) : ?> |
|
129 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
130 | 130 | <?php endif; ?> |
131 | - <?php if( $last !== null ) : ?> |
|
132 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
131 | + <?php if ($last !== null) : ?> |
|
132 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
133 | 133 | <?php endif; ?> |
134 | 134 | <?php endif; ?> |
135 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
135 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
136 | 136 | }, |
137 | 137 | |
138 | - <?php if( isset( $this->errors ) ) : ?> |
|
138 | + <?php if (isset($this->errors)) : ?> |
|
139 | 139 | |
140 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
140 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
141 | 141 | |
142 | - <?php elseif( isset( $this->items ) ) : ?> |
|
142 | + <?php elseif (isset($this->items)) : ?> |
|
143 | 143 | |
144 | 144 | <?php |
145 | 145 | $data = $included = array(); |
146 | - $items = $this->get( 'items', array() ); |
|
146 | + $items = $this->get('items', array()); |
|
147 | 147 | |
148 | - if( is_array( $items ) ) |
|
148 | + if (is_array($items)) |
|
149 | 149 | { |
150 | - foreach( $items as $attrItem ) |
|
150 | + foreach ($items as $attrItem) |
|
151 | 151 | { |
152 | - $data[] = $entryFcn( $attrItem ); |
|
153 | - $included = array_merge( $included, $refFcn( $attrItem, 0 ) ); |
|
152 | + $data[] = $entryFcn($attrItem); |
|
153 | + $included = array_merge($included, $refFcn($attrItem, 0)); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | else |
157 | 157 | { |
158 | - $data = $entryFcn( $items ); |
|
159 | - $included = $refFcn( $items, 0 ); |
|
158 | + $data = $entryFcn($items); |
|
159 | + $included = $refFcn($items, 0); |
|
160 | 160 | } |
161 | 161 | ?> |
162 | 162 | |
163 | - "data": <?php echo json_encode( $data ); ?>, |
|
163 | + "data": <?php echo json_encode($data); ?>, |
|
164 | 164 | |
165 | - "included": <?php echo json_encode( $included ); ?> |
|
165 | + "included": <?php echo json_encode($included); ?> |
|
166 | 166 | |
167 | 167 | <?php endif; ?> |
168 | 168 |
@@ -152,8 +152,7 @@ |
||
152 | 152 | $data[] = $entryFcn( $attrItem ); |
153 | 153 | $included = array_merge( $included, $refFcn( $attrItem, 0 ) ); |
154 | 154 | } |
155 | - } |
|
156 | - else |
|
155 | + } else |
|
157 | 156 | { |
158 | 157 | $data = $entryFcn( $items ); |
159 | 158 | $included = $refFcn( $items, 0 ); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
4 | 4 | <?php endif; ?> |
5 | 5 | |
6 | 6 | } |
@@ -8,38 +8,38 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
12 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
13 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
14 | -$config = $this->config( 'client/jsonapi/url/config', array() ); |
|
11 | +$target = $this->config('client/jsonapi/url/target'); |
|
12 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
13 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
14 | +$config = $this->config('client/jsonapi/url/config', array()); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | $view = $this; |
18 | 18 | $enc = $this->encoder(); |
19 | 19 | |
20 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
21 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
20 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
21 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
22 | 22 | |
23 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
24 | -$limit = max( $this->param( 'page/limit', 100 ), 1 ); |
|
23 | +$offset = max($this->param('page/offset', 0), 0); |
|
24 | +$limit = max($this->param('page/limit', 100), 1); |
|
25 | 25 | |
26 | 26 | |
27 | -$map = $this->get( 'itemMap', array() ); |
|
28 | -$fields = $this->param( 'fields', array() ); |
|
27 | +$map = $this->get('itemMap', array()); |
|
28 | +$fields = $this->param('fields', array()); |
|
29 | 29 | |
30 | -foreach( (array) $fields as $resource => $list ) { |
|
31 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
30 | +foreach ((array) $fields as $resource => $list) { |
|
31 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | -$entryFcn = function( \Aimeos\MShop\Catalog\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config ) |
|
35 | +$entryFcn = function(\Aimeos\MShop\Catalog\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config) |
|
36 | 36 | { |
37 | 37 | $attributes = $item->toArray(); |
38 | 38 | $type = $item->getResourceType(); |
39 | - $params = array( 'resource' => $type, 'id' => $item->getId() ); |
|
39 | + $params = array('resource' => $type, 'id' => $item->getId()); |
|
40 | 40 | |
41 | - if( isset( $fields[$type] ) ) { |
|
42 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
41 | + if (isset($fields[$type])) { |
|
42 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $entry = array( |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | 'type' => $item->getResourceType(), |
48 | 48 | 'links' => array( |
49 | 49 | 'self' => array( |
50 | - 'href' => $view->url( $target, $cntl, $action, $params, array(), $config ), |
|
51 | - 'allow' => array( 'GET' ), |
|
50 | + 'href' => $view->url($target, $cntl, $action, $params, array(), $config), |
|
51 | + 'allow' => array('GET'), |
|
52 | 52 | ), |
53 | 53 | ), |
54 | 54 | 'attributes' => $attributes, |
55 | 55 | ); |
56 | 56 | |
57 | - foreach( $item->getChildren() as $catItem ) { |
|
58 | - $entry['relationships']['catalog']['data'][] = array( 'id' => $catItem->getId(), 'type' => 'catalog' ); |
|
57 | + foreach ($item->getChildren() as $catItem) { |
|
58 | + $entry['relationships']['catalog']['data'][] = array('id' => $catItem->getId(), 'type' => 'catalog'); |
|
59 | 59 | } |
60 | 60 | |
61 | - if( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface ) |
|
61 | + if ($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface) |
|
62 | 62 | { |
63 | - foreach( $item->getListItems() as $listItem ) |
|
63 | + foreach ($item->getListItems() as $listItem) |
|
64 | 64 | { |
65 | 65 | $domain = $listItem->getDomain(); |
66 | 66 | |
67 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
67 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
68 | 68 | $entry['attributes'][$domain][] = $refItem->toArray() + $listItem->toArray(); |
69 | 69 | } |
70 | 70 | |
@@ -78,31 +78,31 @@ discard block |
||
78 | 78 | ?> |
79 | 79 | { |
80 | 80 | "meta": { |
81 | - "total": <?php echo ( isset( $this->items ) ? 1 : 0 ); ?> |
|
81 | + "total": <?php echo (isset($this->items) ? 1 : 0); ?> |
|
82 | 82 | |
83 | 83 | }, |
84 | 84 | |
85 | 85 | "links": { |
86 | - "self": "<?php echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
86 | + "self": "<?php echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
87 | 87 | }, |
88 | 88 | |
89 | - <?php if( isset( $this->errors ) ) : ?> |
|
89 | + <?php if (isset($this->errors)) : ?> |
|
90 | 90 | |
91 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
91 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
92 | 92 | |
93 | - <?php elseif( isset( $this->items ) ) : ?> |
|
93 | + <?php elseif (isset($this->items)) : ?> |
|
94 | 94 | |
95 | 95 | <?php |
96 | 96 | $included = array(); |
97 | 97 | |
98 | - foreach( $this->items->getChildren() as $catItem ) { |
|
99 | - $included[] = $entryFcn( $catItem ); |
|
98 | + foreach ($this->items->getChildren() as $catItem) { |
|
99 | + $included[] = $entryFcn($catItem); |
|
100 | 100 | } |
101 | 101 | ?> |
102 | 102 | |
103 | - "data": <?php echo json_encode( $entryFcn( $this->items ) ); ?>, |
|
103 | + "data": <?php echo json_encode($entryFcn($this->items)); ?>, |
|
104 | 104 | |
105 | - "included": <?php echo json_encode( $included ); ?> |
|
105 | + "included": <?php echo json_encode($included); ?> |
|
106 | 106 | |
107 | 107 | <?php endif; ?> |
108 | 108 |
@@ -31,30 +31,30 @@ discard block |
||
31 | 31 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
32 | 32 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
33 | 33 | */ |
34 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
34 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
35 | 35 | { |
36 | 36 | $view = $this->getView(); |
37 | 37 | |
38 | 38 | try |
39 | 39 | { |
40 | - $response = $this->getItem( $view, $request, $response ); |
|
40 | + $response = $this->getItem($view, $request, $response); |
|
41 | 41 | $status = 200; |
42 | 42 | } |
43 | - catch( \Aimeos\MShop\Exception $e ) |
|
43 | + catch (\Aimeos\MShop\Exception $e) |
|
44 | 44 | { |
45 | 45 | $status = 404; |
46 | - $view->errors = array( array( |
|
47 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
46 | + $view->errors = array(array( |
|
47 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
48 | 48 | 'detail' => $e->getTraceAsString(), |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | } |
51 | - catch( \Exception $e ) |
|
51 | + catch (\Exception $e) |
|
52 | 52 | { |
53 | 53 | $status = 500; |
54 | - $view->errors = array( array( |
|
54 | + $view->errors = array(array( |
|
55 | 55 | 'title' => $e->getMessage(), |
56 | 56 | 'detail' => $e->getTraceAsString(), |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** client/jsonapi/catalog/standard/template-get |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | $tplconf = 'client/jsonapi/catalog/standard/template-get'; |
80 | 80 | $default = 'catalog/get-default.php'; |
81 | 81 | |
82 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
82 | + $body = $view->render($view->config($tplconf, $default)); |
|
83 | 83 | |
84 | - return $response->withHeader( 'Allow', 'GET' ) |
|
85 | - ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
86 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
87 | - ->withStatus( $status ); |
|
84 | + return $response->withHeader('Allow', 'GET') |
|
85 | + ->withHeader('Content-Type', 'application/vnd.api+json') |
|
86 | + ->withBody($view->response()->createStreamFromString($body)) |
|
87 | + ->withStatus($status); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -96,32 +96,32 @@ discard block |
||
96 | 96 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
97 | 97 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
98 | 98 | */ |
99 | - protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
99 | + protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
100 | 100 | { |
101 | 101 | $map = array(); |
102 | - $catId = $view->param( 'id' ); |
|
103 | - $ref = $view->param( 'include', array() ); |
|
102 | + $catId = $view->param('id'); |
|
103 | + $ref = $view->param('include', array()); |
|
104 | 104 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
105 | 105 | |
106 | - if( $catId == '' ) { |
|
106 | + if ($catId == '') { |
|
107 | 107 | $catId = null; |
108 | 108 | } |
109 | 109 | |
110 | - if( is_string( $ref ) ) { |
|
111 | - $ref = explode( ',', $ref ); |
|
110 | + if (is_string($ref)) { |
|
111 | + $ref = explode(',', $ref); |
|
112 | 112 | } |
113 | 113 | |
114 | - if( in_array( 'catalog', $ref, true ) ) { |
|
114 | + if (in_array('catalog', $ref, true)) { |
|
115 | 115 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $context = $this->getContext(); |
119 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
119 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
120 | 120 | |
121 | 121 | $filter = $cntl->createFilter(); |
122 | - $filter = $this->initCriteria( $filter, $view->param() ); |
|
122 | + $filter = $this->initCriteria($filter, $view->param()); |
|
123 | 123 | |
124 | - $view->items = $cntl->getTree( $catId, $ref, $level, $filter ); |
|
124 | + $view->items = $cntl->getTree($catId, $ref, $level, $filter); |
|
125 | 125 | |
126 | 126 | return $response; |
127 | 127 | } |
@@ -39,16 +39,14 @@ |
||
39 | 39 | { |
40 | 40 | $response = $this->getItem( $view, $request, $response ); |
41 | 41 | $status = 200; |
42 | - } |
|
43 | - catch( \Aimeos\MShop\Exception $e ) |
|
42 | + } catch( \Aimeos\MShop\Exception $e ) |
|
44 | 43 | { |
45 | 44 | $status = 404; |
46 | 45 | $view->errors = array( array( |
47 | 46 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
48 | 47 | 'detail' => $e->getTraceAsString(), |
49 | 48 | ) ); |
50 | - } |
|
51 | - catch( \Exception $e ) |
|
49 | + } catch( \Exception $e ) |
|
52 | 50 | { |
53 | 51 | $status = 500; |
54 | 52 | $view->errors = array( array( |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
32 | 32 | * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails |
33 | 33 | */ |
34 | - public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null ) |
|
34 | + public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null) |
|
35 | 35 | { |
36 | - if( ctype_alnum( $path ) === false ) |
|
36 | + if (ctype_alnum($path) === false) |
|
37 | 37 | { |
38 | - $path = ( is_string( $path ) ? $path : '<not a string>' ); |
|
39 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 ); |
|
38 | + $path = (is_string($path) ? $path : '<not a string>'); |
|
39 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** client/jsonapi/catalog/name |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | * @since 2017.03 |
73 | 73 | * @category Developer |
74 | 74 | */ |
75 | - if( $name === null ) { |
|
76 | - $name = $context->getConfig()->get( 'client/jsonapi/catalog/name', 'Standard' ); |
|
75 | + if ($name === null) { |
|
76 | + $name = $context->getConfig()->get('client/jsonapi/catalog/name', 'Standard'); |
|
77 | 77 | } |
78 | 78 | |
79 | - if( ctype_alnum( $name ) === false ) |
|
79 | + if (ctype_alnum($name) === false) |
|
80 | 80 | { |
81 | - $classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name : '<not a string>'; |
|
82 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
81 | + $classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name : '<not a string>'; |
|
82 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $view = $context->getView(); |
86 | 86 | $iface = '\\Aimeos\\Client\\JsonApi\\Iface'; |
87 | 87 | $classname = '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name; |
88 | 88 | |
89 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
89 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
90 | 90 | |
91 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
91 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $classname Full name of the class for which the object should be returned |
32 | 32 | * @param \Aimeos\Client\JsonApi\Iface|null $client JSON API client object |
33 | 33 | */ |
34 | - public static function injectClient( $classname, \Aimeos\Client\JsonApi\Iface $client = null ) |
|
34 | + public static function injectClient($classname, \Aimeos\Client\JsonApi\Iface $client = null) |
|
35 | 35 | { |
36 | 36 | self::$objects[$classname] = $client; |
37 | 37 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
48 | 48 | * @return \Aimeos\Client\JsonApi\Common\Iface Client object |
49 | 49 | */ |
50 | - protected static function addClientDecorators( \Aimeos\Client\JsonApi\Iface $client, |
|
51 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
50 | + protected static function addClientDecorators(\Aimeos\Client\JsonApi\Iface $client, |
|
51 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
52 | 52 | { |
53 | 53 | $config = $context->getConfig(); |
54 | 54 | |
@@ -74,38 +74,38 @@ discard block |
||
74 | 74 | * @since 2015.12 |
75 | 75 | * @category Developer |
76 | 76 | */ |
77 | - $decorators = $config->get( 'client/jsonapi/common/decorators/default', array() ); |
|
77 | + $decorators = $config->get('client/jsonapi/common/decorators/default', array()); |
|
78 | 78 | |
79 | - if( $path !== null && is_string( $path ) ) |
|
79 | + if ($path !== null && is_string($path)) |
|
80 | 80 | { |
81 | - $dpath = trim( $path, '/' ); |
|
82 | - $dpath = ( $dpath !== '' ? $dpath . '/' : $dpath ); |
|
81 | + $dpath = trim($path, '/'); |
|
82 | + $dpath = ($dpath !== '' ? $dpath . '/' : $dpath); |
|
83 | 83 | |
84 | - $excludes = $config->get( 'client/jsonapi/' . $dpath . 'decorators/excludes', array() ); |
|
85 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) ); |
|
84 | + $excludes = $config->get('client/jsonapi/' . $dpath . 'decorators/excludes', array()); |
|
85 | + $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path))); |
|
86 | 86 | |
87 | - foreach( $decorators as $key => $name ) |
|
87 | + foreach ($decorators as $key => $name) |
|
88 | 88 | { |
89 | - if( in_array( $name, $excludes ) ) { |
|
90 | - unset( $decorators[$key] ); |
|
89 | + if (in_array($name, $excludes)) { |
|
90 | + unset($decorators[$key]); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | $classprefix = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
95 | - $decorators = $config->get( 'client/jsonapi/' . $dpath . 'decorators/global', array() ); |
|
96 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
95 | + $decorators = $config->get('client/jsonapi/' . $dpath . 'decorators/global', array()); |
|
96 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
97 | 97 | |
98 | - if( !empty( $path ) ) |
|
98 | + if (!empty($path)) |
|
99 | 99 | { |
100 | - $classprefix = '\\Aimeos\\Client\\JsonApi\\' . ucfirst( $localClass ) . '\\Decorator\\'; |
|
101 | - $decorators = $config->get( 'client/jsonapi/' . $dpath . 'decorators/local', array() ); |
|
102 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
100 | + $classprefix = '\\Aimeos\\Client\\JsonApi\\' . ucfirst($localClass) . '\\Decorator\\'; |
|
101 | + $decorators = $config->get('client/jsonapi/' . $dpath . 'decorators/local', array()); |
|
102 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | else |
106 | 106 | { |
107 | 107 | $classprefix = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
108 | - $client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
108 | + $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return $client; |
@@ -124,29 +124,29 @@ discard block |
||
124 | 124 | * @param string $path Name of the client, e.g "product" |
125 | 125 | * @return \Aimeos\Client\JsonApi\Common\Iface Client object |
126 | 126 | */ |
127 | - protected static function addDecorators( \Aimeos\Client\JsonApi\Iface $client, array $decorators, $classprefix, |
|
128 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
127 | + protected static function addDecorators(\Aimeos\Client\JsonApi\Iface $client, array $decorators, $classprefix, |
|
128 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
129 | 129 | { |
130 | 130 | $iface = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\Iface'; |
131 | 131 | |
132 | - foreach( $decorators as $name ) |
|
132 | + foreach ($decorators as $name) |
|
133 | 133 | { |
134 | - if( ctype_alnum( $name ) === false ) |
|
134 | + if (ctype_alnum($name) === false) |
|
135 | 135 | { |
136 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
137 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid class name "%1$s"', $classname ), 404 ); |
|
136 | + $classname = is_string($name) ? $classprefix . $name : '<not a string>'; |
|
137 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid class name "%1$s"', $classname), 404); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $classname = $classprefix . $name; |
141 | 141 | |
142 | - if( class_exists( $classname ) === false ) { |
|
143 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 ); |
|
142 | + if (class_exists($classname) === false) { |
|
143 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" not found', $classname), 404); |
|
144 | 144 | } |
145 | 145 | |
146 | - $client = new $classname( $client, $context, $view, $templatePaths, $path ); |
|
146 | + $client = new $classname($client, $context, $view, $templatePaths, $path); |
|
147 | 147 | |
148 | - if( !( $client instanceof $iface ) ) { |
|
149 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $iface ), 404 ); |
|
148 | + if (!($client instanceof $iface)) { |
|
149 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" does not implement "%2$s"', $classname, $iface), 404); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
166 | 166 | * @return \Aimeos\Client\JsonApi\Common\Iface Client object |
167 | 167 | */ |
168 | - protected static function createClientBase( $classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, |
|
169 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
168 | + protected static function createClientBase($classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, |
|
169 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
170 | 170 | { |
171 | - if( isset( self::$objects[$classname] ) ) { |
|
171 | + if (isset(self::$objects[$classname])) { |
|
172 | 172 | return self::$objects[$classname]; |
173 | 173 | } |
174 | 174 | |
175 | - if( class_exists( $classname ) === false ) { |
|
176 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 ); |
|
175 | + if (class_exists($classname) === false) { |
|
176 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" not found', $classname), 404); |
|
177 | 177 | } |
178 | 178 | |
179 | - $client = new $classname( $context, $view, $templatePaths, $path ); |
|
179 | + $client = new $classname($context, $view, $templatePaths, $path); |
|
180 | 180 | |
181 | - if( !( $client instanceof $interface ) ) { |
|
182 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $interface ), 500 ); |
|
181 | + if (!($client instanceof $interface)) { |
|
182 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" does not implement "%2$s"', $classname, $interface), 500); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $client; |
@@ -101,8 +101,7 @@ |
||
101 | 101 | $decorators = $config->get( 'client/jsonapi/' . $dpath . 'decorators/local', array() ); |
102 | 102 | $client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
103 | 103 | } |
104 | - } |
|
105 | - else |
|
104 | + } else |
|
106 | 105 | { |
107 | 106 | $classprefix = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
108 | 107 | $client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
@@ -28,5 +28,5 @@ |
||
28 | 28 | * @param string|null $name Name of the client implementation ("Standard" if null) |
29 | 29 | * @return \Aimeos\Admin\JsonAdm\Iface Client Interface |
30 | 30 | */ |
31 | - public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null ); |
|
31 | + public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null); |
|
32 | 32 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * @param array $templatePaths List of file system paths where the templates are stored |
37 | 37 | * @param string $path Name of the client, e.g "product" |
38 | 38 | */ |
39 | - public function __construct( \Aimeos\Client\JsonApi\Iface $client, |
|
40 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
39 | + public function __construct(\Aimeos\Client\JsonApi\Iface $client, |
|
40 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
41 | 41 | { |
42 | - parent::__construct( $context, $view, $templatePaths, $path ); |
|
42 | + parent::__construct($context, $view, $templatePaths, $path); |
|
43 | 43 | |
44 | 44 | $this->client = $client; |
45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return mixed Returns the value of the called method |
54 | 54 | * @throws \Aimeos\Client\JsonApi\Exception If method call failed |
55 | 55 | */ |
56 | - public function __call( $name, array $param ) |
|
56 | + public function __call($name, array $param) |
|
57 | 57 | { |
58 | - return @call_user_func_array( array( $this->client, $name ), $param ); |
|
58 | + return @call_user_func_array(array($this->client, $name), $param); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
67 | 67 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
68 | 68 | */ |
69 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
69 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
70 | 70 | { |
71 | - return $this->client->delete( $request, $response ); |
|
71 | + return $this->client->delete($request, $response); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
80 | 80 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
81 | 81 | */ |
82 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
82 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
83 | 83 | { |
84 | - return $this->client->get( $request, $response ); |
|
84 | + return $this->client->get($request, $response); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
94 | 94 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
95 | 95 | */ |
96 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
96 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
97 | 97 | { |
98 | - return $this->client->patch( $request, $response ); |
|
98 | + return $this->client->patch($request, $response); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
108 | 108 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
109 | 109 | */ |
110 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
110 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
111 | 111 | { |
112 | - return $this->client->post( $request, $response ); |
|
112 | + return $this->client->post($request, $response); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
122 | 122 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
123 | 123 | */ |
124 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
124 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
125 | 125 | { |
126 | - return $this->client->put( $request, $response ); |
|
126 | + return $this->client->put($request, $response); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
137 | 137 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
138 | 138 | */ |
139 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
|
139 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null) |
|
140 | 140 | { |
141 | - return $this->client->options( $request, $response, $prefix ); |
|
141 | + return $this->client->options($request, $response, $prefix); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 |
@@ -29,6 +29,6 @@ |
||
29 | 29 | * @param array $templatePaths List of file system paths where the templates are stored |
30 | 30 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
31 | 31 | */ |
32 | - public function __construct( \Aimeos\Client\JsonApi\Iface $client, |
|
33 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ); |
|
32 | + public function __construct(\Aimeos\Client\JsonApi\Iface $client, |
|
33 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path); |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |