@@ -36,7 +36,7 @@ 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 separated by slashes, e.g "catalog/lists" |
38 | 38 | */ |
39 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
39 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
40 | 40 | { |
41 | 41 | $this->view = $view; |
42 | 42 | $this->context = $context; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @param array $param List of method parameter |
53 | 53 | * @throws \Aimeos\Client\JsonApi\Exception If method call failed |
54 | 54 | */ |
55 | - public function __call( $name, array $param ) |
|
55 | + public function __call($name, array $param) |
|
56 | 56 | { |
57 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
57 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
66 | 66 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
67 | 67 | */ |
68 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
68 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
69 | 69 | { |
70 | - return $this->defaultAction( $request, $response ); |
|
70 | + return $this->defaultAction($request, $response); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
79 | 79 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
80 | 80 | */ |
81 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
81 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
82 | 82 | { |
83 | - return $this->defaultAction( $request, $response ); |
|
83 | + return $this->defaultAction($request, $response); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
92 | 92 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
93 | 93 | */ |
94 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
94 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
95 | 95 | { |
96 | - return $this->defaultAction( $request, $response ); |
|
96 | + return $this->defaultAction($request, $response); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
105 | 105 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
106 | 106 | */ |
107 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
107 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
108 | 108 | { |
109 | - return $this->defaultAction( $request, $response ); |
|
109 | + return $this->defaultAction($request, $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
119 | 119 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
120 | 120 | */ |
121 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
121 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
122 | 122 | { |
123 | - return $this->defaultAction( $request, $response ); |
|
123 | + return $this->defaultAction($request, $response); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
132 | 132 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
133 | 133 | */ |
134 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
|
134 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null) |
|
135 | 135 | { |
136 | - return $this->defaultAction( $request, $response ); |
|
136 | + return $this->defaultAction($request, $response); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
145 | 145 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
146 | 146 | */ |
147 | - protected function defaultAction( ServerRequestInterface $request, ResponseInterface $response ) |
|
147 | + protected function defaultAction(ServerRequestInterface $request, ResponseInterface $response) |
|
148 | 148 | { |
149 | 149 | $status = 403; |
150 | 150 | $view = $this->getView(); |
151 | 151 | |
152 | - $view->errors = array( array( |
|
153 | - 'title' => $this->getContext()->getI18n()->dt( 'client/jsonapi', 'Not allowed for this resource' ), |
|
154 | - ) ); |
|
152 | + $view->errors = array(array( |
|
153 | + 'title' => $this->getContext()->getI18n()->dt('client/jsonapi', 'Not allowed for this resource'), |
|
154 | + )); |
|
155 | 155 | |
156 | 156 | /** client/jsonapi/standard/template-error |
157 | 157 | * Relative path to the default JSON API template |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $tplconf = 'client/jsonapi/standard/template-error'; |
181 | 181 | $default = 'error-default.php'; |
182 | 182 | |
183 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
183 | + $body = $view->render($view->config($tplconf, $default)); |
|
184 | 184 | |
185 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
186 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
187 | - ->withStatus( $status ); |
|
185 | + return $response->withHeader('Content-Type', 'application/vnd.api+json') |
|
186 | + ->withBody($view->response()->createStreamFromString($body)) |
|
187 | + ->withStatus($status); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | * @param array $params List of criteria data with condition, sorting and paging |
240 | 240 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
241 | 241 | */ |
242 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
242 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
243 | 243 | { |
244 | - $this->initCriteriaConditions( $criteria, $params ); |
|
245 | - $this->initCriteriaSortations( $criteria, $params ); |
|
246 | - $this->initCriteriaSlice( $criteria, $params ); |
|
244 | + $this->initCriteriaConditions($criteria, $params); |
|
245 | + $this->initCriteriaSortations($criteria, $params); |
|
246 | + $this->initCriteriaSlice($criteria, $params); |
|
247 | 247 | |
248 | 248 | return $criteria; |
249 | 249 | } |
@@ -256,17 +256,17 @@ discard block |
||
256 | 256 | * @param array $params List of criteria data with condition, sorting and paging |
257 | 257 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
258 | 258 | */ |
259 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
259 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
260 | 260 | { |
261 | - if( !isset( $params['filter'] ) ) { |
|
261 | + if (!isset($params['filter'])) { |
|
262 | 262 | return $criteria; |
263 | 263 | } |
264 | 264 | |
265 | 265 | $existing = $criteria->getConditions(); |
266 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
266 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
267 | 267 | |
268 | - $expr = array( $criteria->getConditions(), $existing ); |
|
269 | - return $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
268 | + $expr = array($criteria->getConditions(), $existing); |
|
269 | + return $criteria->setConditions($criteria->combine('&&', $expr)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * @param array $params List of criteria data with condition, sorting and paging |
278 | 278 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
279 | 279 | */ |
280 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
280 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
281 | 281 | { |
282 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
283 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
282 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
283 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
284 | 284 | |
285 | - return $criteria->setSlice( $start, $size ); |
|
285 | + return $criteria->setSlice($start, $size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -293,23 +293,23 @@ discard block |
||
293 | 293 | * @param array $params List of criteria data with condition, sorting and paging |
294 | 294 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
295 | 295 | */ |
296 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
296 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
297 | 297 | { |
298 | - if( !isset( $params['sort'] ) ) { |
|
298 | + if (!isset($params['sort'])) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | $sortation = array(); |
303 | 303 | |
304 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
304 | + foreach (explode(',', $params['sort']) as $sort) |
|
305 | 305 | { |
306 | - if( $sort[0] === '-' ) { |
|
307 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
306 | + if ($sort[0] === '-') { |
|
307 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
308 | 308 | } else { |
309 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
309 | + $sortation[] = $criteria->sort('+', $sort); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - return $criteria->setSortations( $sortation ); |
|
313 | + return $criteria->setSortations($sortation); |
|
314 | 314 | } |
315 | 315 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
33 | 33 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
34 | 34 | */ |
35 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
|
35 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null) |
|
36 | 36 | { |
37 | 37 | $view = $this->getView(); |
38 | 38 | |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | * @category Developer |
56 | 56 | */ |
57 | 57 | $default = ['attribute', 'catalog', 'product', 'stock']; |
58 | - $resources = $this->getContext()->getConfig()->get( 'client/jsonapi/resources', $default ); |
|
58 | + $resources = $this->getContext()->getConfig()->get('client/jsonapi/resources', $default); |
|
59 | 59 | |
60 | 60 | $view->resources = (array) $resources; |
61 | 61 | $view->prefix = $prefix; |
62 | 62 | $status = 200; |
63 | 63 | } |
64 | - catch( \Exception $e ) |
|
64 | + catch (\Exception $e) |
|
65 | 65 | { |
66 | 66 | $status = 500; |
67 | - $view->errors = array( array( |
|
67 | + $view->errors = array(array( |
|
68 | 68 | 'title' => $e->getMessage(), |
69 | 69 | 'detail' => $e->getTraceAsString(), |
70 | - ) ); |
|
70 | + )); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** client/jsonapi/standard/template-options |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $tplconf = 'client/jsonapi/standard/template-options'; |
98 | 98 | $default = 'options-default.php'; |
99 | 99 | |
100 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
100 | + $body = $view->render($view->config($tplconf, $default)); |
|
101 | 101 | |
102 | - return $response->withHeader( 'Allow', 'GET' ) |
|
103 | - ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
104 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
105 | - ->withStatus( $status ); |
|
102 | + return $response->withHeader('Allow', 'GET') |
|
103 | + ->withHeader('Content-Type', 'application/vnd.api+json') |
|
104 | + ->withBody($view->response()->createStreamFromString($body)) |
|
105 | + ->withStatus($status); |
|
106 | 106 | } |
107 | 107 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
30 | 30 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
31 | 31 | */ |
32 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ); |
|
32 | + public function delete(ServerRequestInterface $request, ResponseInterface $response); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
40 | 40 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
41 | 41 | */ |
42 | - public function get( ServerRequestInterface $request, ResponseInterface $response ); |
|
42 | + public function get(ServerRequestInterface $request, ResponseInterface $response); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
50 | 50 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
51 | 51 | */ |
52 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ); |
|
52 | + public function patch(ServerRequestInterface $request, ResponseInterface $response); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
60 | 60 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
61 | 61 | */ |
62 | - public function post( ServerRequestInterface $request, ResponseInterface $response ); |
|
62 | + public function post(ServerRequestInterface $request, ResponseInterface $response); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
70 | 70 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
71 | 71 | */ |
72 | - public function put( ServerRequestInterface $request, ResponseInterface $response ); |
|
72 | + public function put(ServerRequestInterface $request, ResponseInterface $response); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -80,5 +80,5 @@ discard block |
||
80 | 80 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
81 | 81 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
82 | 82 | */ |
83 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ); |
|
83 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null); |
|
84 | 84 | } |
@@ -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(); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @return \Aimeos\Client\JsonApi\Iface JSON client instance |
66 | 66 | * @throws \Aimeos\Client\JsonApi\Exception If the given path is invalid |
67 | 67 | */ |
68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
69 | - array $templatePaths, $path, $name = null ) |
|
68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
69 | + array $templatePaths, $path, $name = null) |
|
70 | 70 | { |
71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
72 | 72 | |
73 | - if( empty( $path ) ) { |
|
74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
73 | + if (empty($path)) { |
|
74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $id = (string) $context; |
78 | 78 | |
79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
91 | 91 | * @return boolean Previous cache setting |
92 | 92 | */ |
93 | - static public function setCache( $value ) |
|
93 | + static public function setCache($value) |
|
94 | 94 | { |
95 | 95 | $old = self::$cache; |
96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | * @return \Aimeos\Client\JsonApi\Iface JSON client instance |
110 | 110 | * @throws \Aimeos\Client\JsonApi\Exception If the given path is invalid |
111 | 111 | */ |
112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
113 | - array $templatePaths, $path, $name ) |
|
112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
113 | + array $templatePaths, $path, $name) |
|
114 | 114 | { |
115 | - $parts = explode( '/', $path ); |
|
115 | + $parts = explode('/', $path); |
|
116 | 116 | |
117 | - foreach( $parts as $key => $part ) |
|
117 | + foreach ($parts as $key => $part) |
|
118 | 118 | { |
119 | - if( ctype_alnum( $part ) === false ) |
|
119 | + if (ctype_alnum($part) === false) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
122 | - throw new \Aimeos\Client\JsonApi\Exception( $msg, 400 ); |
|
121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
122 | + throw new \Aimeos\Client\JsonApi\Exception($msg, 400); |
|
123 | 123 | } |
124 | 124 | |
125 | - $parts[$key] = ucwords( $part ); |
|
125 | + $parts[$key] = ucwords($part); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | $view = $context->getView(); |
130 | - $factory = '\\Aimeos\\Client\\JsonApi\\' . join( '\\', $parts ) . '\\Factory'; |
|
130 | + $factory = '\\Aimeos\\Client\\JsonApi\\' . join('\\', $parts) . '\\Factory'; |
|
131 | 131 | |
132 | - if( class_exists( $factory ) === true ) |
|
132 | + if (class_exists($factory) === true) |
|
133 | 133 | { |
134 | - $args = array( $context, $templatePaths, $path, $name ); |
|
134 | + $args = array($context, $templatePaths, $path, $name); |
|
135 | 135 | |
136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
137 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
137 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return \Aimeos\Client\JsonApi\Iface JSON client instance |
158 | 158 | * @throws \Aimeos\Client\JsonApi\Exception If the client couldn't be created |
159 | 159 | */ |
160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
162 | 162 | { |
163 | 163 | /** client/jsonapi/name |
164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @since 2015.12 |
194 | 194 | * @category Developer |
195 | 195 | */ |
196 | - if( $name === null ) { |
|
197 | - $name = $context->getConfig()->get( 'client/jsonapi/name', 'Standard' ); |
|
196 | + if ($name === null) { |
|
197 | + $name = $context->getConfig()->get('client/jsonapi/name', 'Standard'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if( ctype_alnum( $name ) === false ) |
|
200 | + if (ctype_alnum($name) === false) |
|
201 | 201 | { |
202 | - $classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\' . $name : '<not a string>'; |
|
203 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
202 | + $classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\' . $name : '<not a string>'; |
|
203 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $iface = '\\Aimeos\\Client\\JsonApi\\Iface'; |
207 | 207 | $classname = '\\Aimeos\\Client\\JsonApi\\' . $name; |
208 | 208 | |
209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
210 | 210 | |
211 | 211 | /** client/jsonapi/decorators/excludes |
212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
286 | 286 | * @see client/jsonapi/decorators/global |
287 | 287 | */ |
288 | 288 | |
289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
290 | 290 | } |
291 | 291 | } |
@@ -31,35 +31,35 @@ 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 | - if( $view->param( 'id' ) != '' ) { |
|
41 | - $response = $this->getItem( $view, $request, $response ); |
|
40 | + if ($view->param('id') != '') { |
|
41 | + $response = $this->getItem($view, $request, $response); |
|
42 | 42 | } else { |
43 | - $response = $this->getItems( $view, $request, $response ); |
|
43 | + $response = $this->getItems($view, $request, $response); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $status = 200; |
47 | 47 | } |
48 | - catch( \Aimeos\MShop\Exception $e ) |
|
48 | + catch (\Aimeos\MShop\Exception $e) |
|
49 | 49 | { |
50 | 50 | $status = 404; |
51 | - $view->errors = array( array( |
|
52 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
51 | + $view->errors = array(array( |
|
52 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
53 | 53 | 'detail' => $e->getTraceAsString(), |
54 | - ) ); |
|
54 | + )); |
|
55 | 55 | } |
56 | - catch( \Exception $e ) |
|
56 | + catch (\Exception $e) |
|
57 | 57 | { |
58 | 58 | $status = 500; |
59 | - $view->errors = array( array( |
|
59 | + $view->errors = array(array( |
|
60 | 60 | 'title' => $e->getMessage(), |
61 | 61 | 'detail' => $e->getTraceAsString(), |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** client/jsonapi/attribute/standard/template-get |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | $tplconf = 'client/jsonapi/attribute/standard/template-get'; |
85 | 85 | $default = 'attribute/get-default.php'; |
86 | 86 | |
87 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
87 | + $body = $view->render($view->config($tplconf, $default)); |
|
88 | 88 | |
89 | - return $response->withHeader( 'Allow', 'GET' ) |
|
90 | - ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
91 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
92 | - ->withStatus( $status ); |
|
89 | + return $response->withHeader('Allow', 'GET') |
|
90 | + ->withHeader('Content-Type', 'application/vnd.api+json') |
|
91 | + ->withBody($view->response()->createStreamFromString($body)) |
|
92 | + ->withStatus($status); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,17 +101,17 @@ discard block |
||
101 | 101 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
102 | 102 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
103 | 103 | */ |
104 | - protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
104 | + protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
105 | 105 | { |
106 | - $ref = $view->param( 'include', array() ); |
|
106 | + $ref = $view->param('include', array()); |
|
107 | 107 | |
108 | - if( is_string( $ref ) ) { |
|
109 | - $ref = explode( ',', $ref ); |
|
108 | + if (is_string($ref)) { |
|
109 | + $ref = explode(',', $ref); |
|
110 | 110 | } |
111 | 111 | |
112 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'attribute' ); |
|
112 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'attribute'); |
|
113 | 113 | |
114 | - $view->items = $cntl->getItem( $view->param( 'id' ), $ref ); |
|
114 | + $view->items = $cntl->getItem($view->param('id'), $ref); |
|
115 | 115 | $view->total = 1; |
116 | 116 | |
117 | 117 | return $response; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
127 | 127 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
128 | 128 | */ |
129 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
129 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
130 | 130 | { |
131 | 131 | /** client/jsonapi/attribute/types |
132 | 132 | * List of attribute types that should be displayed in this order in the catalog filter |
@@ -146,37 +146,37 @@ discard block |
||
146 | 146 | * @since 2017.03 |
147 | 147 | * @category Developer |
148 | 148 | */ |
149 | - $attrTypes = $this->getContext()->getConfig()->get( 'client/jsonapi/attribute/types', array() ); |
|
149 | + $attrTypes = $this->getContext()->getConfig()->get('client/jsonapi/attribute/types', array()); |
|
150 | 150 | |
151 | 151 | $total = 0; |
152 | 152 | $attrMap = []; |
153 | 153 | |
154 | - $ref = $view->param( 'include', array() ); |
|
154 | + $ref = $view->param('include', array()); |
|
155 | 155 | |
156 | - if( is_string( $ref ) ) { |
|
157 | - $ref = explode( ',', $ref ); |
|
156 | + if (is_string($ref)) { |
|
157 | + $ref = explode(',', $ref); |
|
158 | 158 | } |
159 | 159 | |
160 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'attribute' ); |
|
160 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'attribute'); |
|
161 | 161 | |
162 | 162 | $filter = $cntl->createFilter(); |
163 | - $filter = $this->initCriteriaConditions( $filter, $view->param() ); |
|
164 | - $filter = $cntl->addFilterTypes( $filter, $attrTypes ); |
|
163 | + $filter = $this->initCriteriaConditions($filter, $view->param()); |
|
164 | + $filter = $cntl->addFilterTypes($filter, $attrTypes); |
|
165 | 165 | |
166 | - $items = $cntl->searchItems( $filter, $ref, $total ); |
|
166 | + $items = $cntl->searchItems($filter, $ref, $total); |
|
167 | 167 | |
168 | - foreach( $items as $id => $item ) { |
|
168 | + foreach ($items as $id => $item) { |
|
169 | 169 | $attrMap[$item->getType()][$id] = $item; |
170 | 170 | } |
171 | 171 | |
172 | - if( !empty( $attrTypes ) ) |
|
172 | + if (!empty($attrTypes)) |
|
173 | 173 | { |
174 | 174 | $sorted = []; |
175 | 175 | |
176 | - foreach( $attrTypes as $type ) |
|
176 | + foreach ($attrTypes as $type) |
|
177 | 177 | { |
178 | - if( isset( $attrMap[$type] ) ) { |
|
179 | - $sorted = array_merge( $sorted, $attrMap[$type] ); |
|
178 | + if (isset($attrMap[$type])) { |
|
179 | + $sorted = array_merge($sorted, $attrMap[$type]); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 |
@@ -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/attribute/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/attribute/name', 'Standard' ); |
|
75 | + if ($name === null) { |
|
76 | + $name = $context->getConfig()->get('client/jsonapi/attribute/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\\Attribute\\' . $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\\Attribute\\' . $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\\Attribute\\' . $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,35 +31,35 @@ 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 | - if( $view->param( 'id' ) != '' ) { |
|
41 | - $response = $this->getItem( $view, $request, $response ); |
|
40 | + if ($view->param('id') != '') { |
|
41 | + $response = $this->getItem($view, $request, $response); |
|
42 | 42 | } else { |
43 | - $response = $this->getItems( $view, $request, $response ); |
|
43 | + $response = $this->getItems($view, $request, $response); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $status = 200; |
47 | 47 | } |
48 | - catch( \Aimeos\MShop\Exception $e ) |
|
48 | + catch (\Aimeos\MShop\Exception $e) |
|
49 | 49 | { |
50 | 50 | $status = 404; |
51 | - $view->errors = array( array( |
|
52 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
51 | + $view->errors = array(array( |
|
52 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
53 | 53 | 'detail' => $e->getTraceAsString(), |
54 | - ) ); |
|
54 | + )); |
|
55 | 55 | } |
56 | - catch( \Exception $e ) |
|
56 | + catch (\Exception $e) |
|
57 | 57 | { |
58 | 58 | $status = 500; |
59 | - $view->errors = array( array( |
|
59 | + $view->errors = array(array( |
|
60 | 60 | 'title' => $e->getMessage(), |
61 | 61 | 'detail' => $e->getTraceAsString(), |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** client/jsonapi/locale/standard/template-get |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | $tplconf = 'client/jsonapi/locale/standard/template-get'; |
85 | 85 | $default = 'locale/get-default.php'; |
86 | 86 | |
87 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
87 | + $body = $view->render($view->config($tplconf, $default)); |
|
88 | 88 | |
89 | - return $response->withHeader( 'Allow', 'GET' ) |
|
90 | - ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
91 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
92 | - ->withStatus( $status ); |
|
89 | + return $response->withHeader('Allow', 'GET') |
|
90 | + ->withHeader('Content-Type', 'application/vnd.api+json') |
|
91 | + ->withBody($view->response()->createStreamFromString($body)) |
|
92 | + ->withStatus($status); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
102 | 102 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
103 | 103 | */ |
104 | - protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
104 | + protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
105 | 105 | { |
106 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'locale' ); |
|
106 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'locale'); |
|
107 | 107 | |
108 | - $view->items = $cntl->getItem( $view->param( 'id' ) ); |
|
108 | + $view->items = $cntl->getItem($view->param('id')); |
|
109 | 109 | $view->total = 1; |
110 | 110 | |
111 | 111 | return $response; |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
121 | 121 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
122 | 122 | */ |
123 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
123 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
124 | 124 | { |
125 | 125 | $total = 0; |
126 | 126 | |
127 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'locale' ); |
|
127 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'locale'); |
|
128 | 128 | |
129 | 129 | $filter = $cntl->createFilter(); |
130 | - $filter = $this->initCriteriaConditions( $filter, $view->param() ); |
|
130 | + $filter = $this->initCriteriaConditions($filter, $view->param()); |
|
131 | 131 | |
132 | - $view->items = $cntl->searchItems( $filter, [], $total ); |
|
132 | + $view->items = $cntl->searchItems($filter, [], $total); |
|
133 | 133 | $view->total = $total; |
134 | 134 | |
135 | 135 | return $response; |
@@ -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/locale/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/locale/name', 'Standard' ); |
|
75 | + if ($name === null) { |
|
76 | + $name = $context->getConfig()->get('client/jsonapi/locale/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\\Locale\\' . $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\\Locale\\' . $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\\Locale\\' . $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 | } |
@@ -8,37 +8,37 @@ 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 | -$fields = $this->param( 'fields', array() ); |
|
27 | +$fields = $this->param('fields', array()); |
|
28 | 28 | |
29 | -foreach( (array) $fields as $resource => $list ) { |
|
30 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
29 | +foreach ((array) $fields as $resource => $list) { |
|
30 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | -$entryFcn = function( \Aimeos\MShop\Locale\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config ) |
|
34 | +$entryFcn = function(\Aimeos\MShop\Locale\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config) |
|
35 | 35 | { |
36 | 36 | $attributes = $item->toArray(); |
37 | 37 | $type = $item->getResourceType(); |
38 | - $params = array( 'resource' => $type, 'id' => $item->getId() ); |
|
38 | + $params = array('resource' => $type, 'id' => $item->getId()); |
|
39 | 39 | |
40 | - if( isset( $fields[$type] ) ) { |
|
41 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
40 | + if (isset($fields[$type])) { |
|
41 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $entry = array( |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | 'type' => $item->getResourceType(), |
47 | 47 | 'links' => array( |
48 | 48 | 'self' => array( |
49 | - 'href' => $view->url( $target, $cntl, $action, $params, array(), $config ), |
|
50 | - 'allow' => array( 'GET' ), |
|
49 | + 'href' => $view->url($target, $cntl, $action, $params, array(), $config), |
|
50 | + 'allow' => array('GET'), |
|
51 | 51 | ), |
52 | 52 | ), |
53 | 53 | 'attributes' => $attributes, |
@@ -60,37 +60,37 @@ discard block |
||
60 | 60 | ?> |
61 | 61 | { |
62 | 62 | "meta": { |
63 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
63 | + "total": <?php echo $this->get('total', 0); ?> |
|
64 | 64 | |
65 | 65 | }, |
66 | 66 | |
67 | 67 | "links": { |
68 | - "self": "<?php echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
68 | + "self": "<?php echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
69 | 69 | }, |
70 | 70 | |
71 | - <?php if( isset( $this->errors ) ) : ?> |
|
71 | + <?php if (isset($this->errors)) : ?> |
|
72 | 72 | |
73 | - "errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?> |
|
73 | + "errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?> |
|
74 | 74 | |
75 | - <?php elseif( isset( $this->items ) ) : ?> |
|
75 | + <?php elseif (isset($this->items)) : ?> |
|
76 | 76 | |
77 | 77 | <?php |
78 | 78 | $data = []; |
79 | - $items = $this->get( 'items', [] ); |
|
79 | + $items = $this->get('items', []); |
|
80 | 80 | |
81 | - if( is_array( $items ) ) |
|
81 | + if (is_array($items)) |
|
82 | 82 | { |
83 | - foreach( $items as $localeItem ) { |
|
84 | - $data[] = $entryFcn( $localeItem ); |
|
83 | + foreach ($items as $localeItem) { |
|
84 | + $data[] = $entryFcn($localeItem); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
89 | - $data = $entryFcn( $items ); |
|
89 | + $data = $entryFcn($items); |
|
90 | 90 | } |
91 | 91 | ?> |
92 | 92 | |
93 | - "data": <?php echo json_encode( $data ); ?> |
|
93 | + "data": <?php echo json_encode($data); ?> |
|
94 | 94 | |
95 | 95 | <?php endif; ?> |
96 | 96 |