@@ -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(), 'price/lists' ); |
|
112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price/lists'); |
|
113 | 113 | |
114 | 114 | $search = $manager->createSearch(); |
115 | 115 | $expr = array( |
116 | - $search->compare( '==', 'price.lists.parentid', array_keys( $items ) ), |
|
117 | - $search->compare( '==', 'price.lists.domain', $include ), |
|
116 | + $search->compare('==', 'price.lists.parentid', array_keys($items)), |
|
117 | + $search->compare('==', 'price.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 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
35 | 35 | */ |
36 | - static public function clear( $id = null, $path = null ) |
|
36 | + static public function clear($id = null, $path = null) |
|
37 | 37 | { |
38 | - if( $id !== null ) |
|
38 | + if ($id !== null) |
|
39 | 39 | { |
40 | - if( $path !== null ) { |
|
40 | + if ($path !== null) { |
|
41 | 41 | self::$clients[$id][$path] = null; |
42 | 42 | } else { |
43 | 43 | self::$clients[$id] = array(); |
@@ -64,47 +64,47 @@ discard block |
||
64 | 64 | * @param string|null $name Name of the client implementation ("Standard" if null) |
65 | 65 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
66 | 66 | */ |
67 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
68 | - array $templatePaths, $path, $name = null ) |
|
67 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
68 | + array $templatePaths, $path, $name = null) |
|
69 | 69 | { |
70 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
70 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
71 | 71 | |
72 | - if( empty( $path ) ) { |
|
73 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
72 | + if (empty($path)) { |
|
73 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $id = (string) $context; |
77 | 77 | |
78 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) |
|
78 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) |
|
79 | 79 | { |
80 | - $parts = explode( '/', $path ); |
|
80 | + $parts = explode('/', $path); |
|
81 | 81 | |
82 | - foreach( $parts as $key => $part ) |
|
82 | + foreach ($parts as $key => $part) |
|
83 | 83 | { |
84 | - if( ctype_alnum( $part ) === false ) |
|
84 | + if (ctype_alnum($part) === false) |
|
85 | 85 | { |
86 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
87 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
86 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
87 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
88 | 88 | } |
89 | 89 | |
90 | - $parts[$key] = ucwords( $part ); |
|
90 | + $parts[$key] = ucwords($part); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | 94 | $view = $context->getView(); |
95 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
95 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
96 | 96 | |
97 | - if( class_exists( $factory ) === true ) |
|
97 | + if (class_exists($factory) === true) |
|
98 | 98 | { |
99 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
99 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
100 | 100 | |
101 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
102 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
101 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
102 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | else |
106 | 106 | { |
107 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
107 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param boolean $value True to enable caching, false to disable it. |
122 | 122 | * @return boolean Previous cache setting |
123 | 123 | */ |
124 | - static public function setCache( $value ) |
|
124 | + static public function setCache($value) |
|
125 | 125 | { |
126 | 126 | $old = self::$cache; |
127 | 127 | self::$cache = (boolean) $value; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * @param string|null $name Name of the JsonAdm client (default: "Standard") |
141 | 141 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
142 | 142 | */ |
143 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
144 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
143 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
144 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
145 | 145 | { |
146 | 146 | /** admin/jsonadm/name |
147 | 147 | * Class name of the used JSON API client implementation |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | * @since 2015.12 |
177 | 177 | * @category Developer |
178 | 178 | */ |
179 | - if( $name === null ) { |
|
180 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
179 | + if ($name === null) { |
|
180 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
181 | 181 | } |
182 | 182 | |
183 | - if( ctype_alnum( $name ) === false ) |
|
183 | + if (ctype_alnum($name) === false) |
|
184 | 184 | { |
185 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
186 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
185 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
186 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
190 | 190 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
191 | 191 | |
192 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
192 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
193 | 193 | |
194 | 194 | /** admin/jsonadm/decorators/excludes |
195 | 195 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -269,6 +269,6 @@ discard block |
||
269 | 269 | * @see admin/jsonadm/decorators/global |
270 | 270 | */ |
271 | 271 | |
272 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
272 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
273 | 273 | } |
274 | 274 | } |
@@ -101,8 +101,7 @@ |
||
101 | 101 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
102 | 102 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
103 | 103 | } |
104 | - } |
|
105 | - else |
|
104 | + } else |
|
106 | 105 | { |
107 | 106 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
108 | 107 | } |
@@ -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,19 +1,19 @@ 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\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems ) |
|
9 | +$build = function(\Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | 14 | |
15 | - if( isset( $fields[$type] ) ) { |
|
16 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
15 | + if (isset($fields[$type])) { |
|
16 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $result = array( |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | 'relationships' => array() |
24 | 24 | ); |
25 | 25 | |
26 | - foreach( $childItems as $childItem ) |
|
26 | + foreach ($childItems as $childItem) |
|
27 | 27 | { |
28 | - if( $childItem->getParentId() == $id ) |
|
28 | + if ($childItem->getParentId() == $id) |
|
29 | 29 | { |
30 | 30 | $type = $childItem->getResourceType(); |
31 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
31 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - foreach( $listItems as $listItem ) |
|
35 | + foreach ($listItems as $listItem) |
|
36 | 36 | { |
37 | - if( $listItem->getParentId() == $id ) |
|
37 | + if ($listItem->getParentId() == $id) |
|
38 | 38 | { |
39 | 39 | $type = $listItem->getDomain(); |
40 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $listItem->getRefId(), 'type' => $type, 'attributes' => $listItem->toArray() ) ); |
|
40 | + $result['relationships'][$type][] = array('data' => array('id' => $listItem->getRefId(), 'type' => $type, 'attributes' => $listItem->toArray())); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | |
48 | -$fields = $this->param( 'fields', array() ); |
|
48 | +$fields = $this->param('fields', array()); |
|
49 | 49 | |
50 | -foreach( (array) $fields as $resource => $list ) { |
|
51 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
50 | +foreach ((array) $fields as $resource => $list) { |
|
51 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | -$data = $this->get( 'data', array() ); |
|
56 | -$childItems = $this->get( 'childItems', array() ); |
|
57 | -$listItems = $this->get( 'listItems', array() ); |
|
55 | +$data = $this->get('data', array()); |
|
56 | +$childItems = $this->get('childItems', array()); |
|
57 | +$listItems = $this->get('listItems', array()); |
|
58 | 58 | |
59 | -if( is_array( $data ) ) |
|
59 | +if (is_array($data)) |
|
60 | 60 | { |
61 | 61 | $response = array(); |
62 | 62 | |
63 | - foreach( $data as $item ) { |
|
64 | - $response[] = $build( $item, $fields, $childItems, $listItems ); |
|
63 | + foreach ($data as $item) { |
|
64 | + $response[] = $build($item, $fields, $childItems, $listItems); |
|
65 | 65 | } |
66 | 66 | } |
67 | -elseif( $data !== null ) |
|
67 | +elseif ($data !== null) |
|
68 | 68 | { |
69 | - $response = $build( $data, $fields, $childItems, $listItems ); |
|
69 | + $response = $build($data, $fields, $childItems, $listItems); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
@@ -74,4 +74,4 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | -echo json_encode( $response, $options ); |
|
78 | 77 | \ No newline at end of file |
78 | +echo json_encode($response, $options); |
|
79 | 79 | \ 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,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 |
@@ -1,19 +1,19 @@ 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\MShop\Common\Item\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $baseId = $item->getBaseId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | 14 | |
15 | - if( isset( $fields[$type] ) ) { |
|
16 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
15 | + if (isset($fields[$type])) { |
|
16 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $result = array( |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | 'relationships' => array() |
24 | 24 | ); |
25 | 25 | |
26 | - foreach( $childItems as $childItem ) |
|
26 | + foreach ($childItems as $childItem) |
|
27 | 27 | { |
28 | - if( $childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
28 | + if ($childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
29 | 29 | || $childItem instanceof \Aimeos\MShop\Order\Item\Base\Iface && $childItem->getId() == $baseId |
30 | 30 | ) { |
31 | 31 | $type = $childItem->getResourceType(); |
32 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
32 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
@@ -37,27 +37,27 @@ discard block |
||
37 | 37 | }; |
38 | 38 | |
39 | 39 | |
40 | -$fields = $this->param( 'fields', array() ); |
|
40 | +$fields = $this->param('fields', array()); |
|
41 | 41 | |
42 | -foreach( (array) $fields as $resource => $list ) { |
|
43 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
42 | +foreach ((array) $fields as $resource => $list) { |
|
43 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | -$data = $this->get( 'data', array() ); |
|
48 | -$childItems = $this->get( 'childItems', array() ); |
|
47 | +$data = $this->get('data', array()); |
|
48 | +$childItems = $this->get('childItems', array()); |
|
49 | 49 | |
50 | -if( is_array( $data ) ) |
|
50 | +if (is_array($data)) |
|
51 | 51 | { |
52 | 52 | $response = array(); |
53 | 53 | |
54 | - foreach( $data as $item ) { |
|
55 | - $response[] = $build( $item, $fields, $childItems ); |
|
54 | + foreach ($data as $item) { |
|
55 | + $response[] = $build($item, $fields, $childItems); |
|
56 | 56 | } |
57 | 57 | } |
58 | -elseif( $data !== null ) |
|
58 | +elseif ($data !== null) |
|
59 | 59 | { |
60 | - $response = $build( $data, $fields, $childItems ); |
|
60 | + $response = $build($data, $fields, $childItems); |
|
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
@@ -65,4 +65,4 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | -echo json_encode( $response, $options ); |
|
69 | 68 | \ No newline at end of file |
69 | +echo json_encode($response, $options); |
|
70 | 70 | \ 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 | } |