@@ -107,17 +107,17 @@ |
||
107 | 107 | * @param array $include List of resource types that should be fetched |
108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
109 | 109 | */ |
110 | - protected function getListItems( array $items, array $include ) |
|
110 | + protected function getListItems(array $items, array $include) |
|
111 | 111 | { |
112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute/lists' ); |
|
112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute/lists'); |
|
113 | 113 | |
114 | 114 | $search = $manager->createSearch(); |
115 | 115 | $expr = array( |
116 | - $search->compare( '==', 'attribute.lists.parentid', array_keys( $items ) ), |
|
117 | - $search->compare( '==', 'attribute.lists.domain', $include ), |
|
116 | + $search->compare('==', 'attribute.lists.parentid', array_keys($items)), |
|
117 | + $search->compare('==', 'attribute.lists.domain', $include), |
|
118 | 118 | ); |
119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
119 | + $search->setConditions($search->combine('&&', $expr)); |
|
120 | 120 | |
121 | - return $manager->searchItems( $search ); |
|
121 | + return $manager->searchItems($search); |
|
122 | 122 | } |
123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
107 | 107 | * @param array $include List of resource types that should be fetched |
108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
109 | 109 | */ |
110 | - protected function getListItems( array $items, array $include ) |
|
110 | + protected function getListItems(array $items, array $include) |
|
111 | 111 | { |
112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service/lists' ); |
|
112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service/lists'); |
|
113 | 113 | |
114 | 114 | $search = $manager->createSearch(); |
115 | 115 | $expr = array( |
116 | - $search->compare( '==', 'service.lists.parentid', array_keys( $items ) ), |
|
117 | - $search->compare( '==', 'service.lists.domain', $include ), |
|
116 | + $search->compare('==', 'service.lists.parentid', array_keys($items)), |
|
117 | + $search->compare('==', 'service.lists.domain', $include), |
|
118 | 118 | ); |
119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
119 | + $search->setConditions($search->combine('&&', $expr)); |
|
120 | 120 | |
121 | - return $manager->searchItems( $search ); |
|
121 | + return $manager->searchItems($search); |
|
122 | 122 | } |
123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
107 | 107 | * @param array $include List of resource types that should be fetched |
108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
109 | 109 | */ |
110 | - protected function getListItems( array $items, array $include ) |
|
110 | + protected function getListItems(array $items, array $include) |
|
111 | 111 | { |
112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'media/lists' ); |
|
112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'media/lists'); |
|
113 | 113 | |
114 | 114 | $search = $manager->createSearch(); |
115 | 115 | $expr = array( |
116 | - $search->compare( '==', 'media.lists.parentid', array_keys( $items ) ), |
|
117 | - $search->compare( '==', 'media.lists.domain', $include ), |
|
116 | + $search->compare('==', 'media.lists.parentid', array_keys($items)), |
|
117 | + $search->compare('==', 'media.lists.domain', $include), |
|
118 | 118 | ); |
119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
119 | + $search->setConditions($search->combine('&&', $expr)); |
|
120 | 120 | |
121 | - return $manager->searchItems( $search ); |
|
121 | + return $manager->searchItems($search); |
|
122 | 122 | } |
123 | 123 | } |
@@ -1,9 +1,9 @@ |
||
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 | -echo json_encode( $this->get( 'errors', array() ), $options ); |
|
10 | 9 | \ No newline at end of file |
10 | +echo json_encode($this->get('errors', array()), $options); |
|
11 | 11 | \ No newline at end of file |
@@ -1,28 +1,28 @@ 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, array $items, array $fields ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, array $items, array $fields) |
|
10 | 10 | { |
11 | 11 | $list = array(); |
12 | 12 | |
13 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
14 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
15 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
16 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
13 | + $target = $view->config('admin/jsonadm/url/target'); |
|
14 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
15 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
16 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
17 | 17 | |
18 | - foreach( (array) $items as $item ) |
|
18 | + foreach ((array) $items as $item) |
|
19 | 19 | { |
20 | 20 | $id = $item->getId(); |
21 | 21 | $attributes = $item->toArray(); |
22 | 22 | $type = $item->getResourceType(); |
23 | 23 | |
24 | - if( isset( $fields[$type] ) ) { |
|
25 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
24 | + if (isset($fields[$type])) { |
|
25 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $list[] = array( |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | 'type' => $type, |
31 | 31 | 'attributes' => $attributes, |
32 | 32 | 'links' => array( |
33 | - 'self' => $view->url( $target, $cntl, $action, array( 'resource' => $type, 'id' => $id ), array(), $config ), |
|
33 | + 'self' => $view->url($target, $cntl, $action, array('resource' => $type, 'id' => $id), array(), $config), |
|
34 | 34 | 'related' => array( |
35 | - 'href' => $view->url( $target, $cntl, $action, array( 'resource' => $type, 'id' => null ), array(), $config ) |
|
35 | + 'href' => $view->url($target, $cntl, $action, array('resource' => $type, 'id' => null), array(), $config) |
|
36 | 36 | ) |
37 | 37 | ) |
38 | 38 | ); |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | |
44 | 44 | |
45 | 45 | $response = array(); |
46 | -$fields = $this->param( 'fields', array() ); |
|
46 | +$fields = $this->param('fields', array()); |
|
47 | 47 | |
48 | -foreach( (array) $fields as $resource => $list ) { |
|
49 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
48 | +foreach ((array) $fields as $resource => $list) { |
|
49 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
50 | 50 | } |
51 | 51 | |
52 | -$response = $build( $this, $this->get( 'childItems', array() ), $fields ); |
|
53 | -$response = array_merge( $response, $build( $this, $this->get( 'refItems', array() ), $fields ) ); |
|
52 | +$response = $build($this, $this->get('childItems', array()), $fields); |
|
53 | +$response = array_merge($response, $build($this, $this->get('refItems', array()), $fields)); |
|
54 | 54 | |
55 | 55 | |
56 | -echo json_encode( $response, $options ); |
|
57 | 56 | \ No newline at end of file |
57 | +echo json_encode($response, $options); |
|
58 | 58 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -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,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -1,29 +1,29 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
4 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
5 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
6 | -$config = $this->config( 'admin/jsonadm/url/config', array() ); |
|
3 | +$target = $this->config('admin/jsonadm/url/target'); |
|
4 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
5 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
6 | +$config = $this->config('admin/jsonadm/url/config', array()); |
|
7 | 7 | |
8 | 8 | $resources = $attributes = array(); |
9 | -$site = $this->param( 'site', 'default' ); |
|
9 | +$site = $this->param('site', 'default'); |
|
10 | 10 | |
11 | -foreach( $this->get( 'resources', array() ) as $resource ) { |
|
12 | - $resources[$resource] = $this->url( $target, $cntl, $action, array( 'site' => $site, 'resource' => $resource, 'id' => '' ), array(), $config ); |
|
11 | +foreach ($this->get('resources', array()) as $resource) { |
|
12 | + $resources[$resource] = $this->url($target, $cntl, $action, array('site' => $site, 'resource' => $resource, 'id' => ''), array(), $config); |
|
13 | 13 | } |
14 | 14 | |
15 | -foreach( $this->get( 'attributes', array() ) as $attr ) { |
|
15 | +foreach ($this->get('attributes', array()) as $attr) { |
|
16 | 16 | $attributes[$attr->getCode()] = $attr->toArray(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | ?> |
20 | 20 | { |
21 | 21 | "meta": { |
22 | - "resources": <?php echo json_encode( $resources ); ?>, |
|
23 | - "attributes": <?php echo json_encode( $attributes ); ?> |
|
22 | + "resources": <?php echo json_encode($resources); ?>, |
|
23 | + "attributes": <?php echo json_encode($attributes); ?> |
|
24 | 24 | } |
25 | -<?php if( isset( $this->errors ) ) : ?> |
|
26 | - ,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
25 | +<?php if (isset($this->errors)) : ?> |
|
26 | + ,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | 29 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
4 | 4 | <?php endif; ?> |
5 | 5 | |
6 | 6 | } |