@@ -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 | } |
@@ -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; |
@@ -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 |
@@ -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/stock/standard/template-get |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | $tplconf = 'client/jsonapi/stock/standard/template-get'; |
85 | 85 | $default = 'stock/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,12 +101,12 @@ 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 | 106 | $context = $this->getContext(); |
107 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'stock' ); |
|
107 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'stock'); |
|
108 | 108 | |
109 | - $view->items = $cntl->getItem( $view->param( 'id' ) ); |
|
109 | + $view->items = $cntl->getItem($view->param('id')); |
|
110 | 110 | $view->total = 1; |
111 | 111 | |
112 | 112 | return $response; |
@@ -121,20 +121,20 @@ 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 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
124 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
125 | 125 | { |
126 | 126 | $total = 0; |
127 | - $params = $view->param( 'filter', [] ); |
|
128 | - unset( $params['s_prodcode'], $params['s_typecode'] ); |
|
127 | + $params = $view->param('filter', []); |
|
128 | + unset($params['s_prodcode'], $params['s_typecode']); |
|
129 | 129 | |
130 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'stock' ); |
|
130 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'stock'); |
|
131 | 131 | |
132 | 132 | $filter = $cntl->createFilter(); |
133 | - $filter = $this->initCriteria( $filter, ['filter' => $params] ); |
|
134 | - $filter = $cntl->addFilterCodes( $filter, $view->param( 'filter/s_prodcode', array() ) ); |
|
135 | - $filter = $cntl->addFilterTypes( $filter, $view->param( 'filter/s_typecode', array() ) ); |
|
133 | + $filter = $this->initCriteria($filter, ['filter' => $params]); |
|
134 | + $filter = $cntl->addFilterCodes($filter, $view->param('filter/s_prodcode', array())); |
|
135 | + $filter = $cntl->addFilterTypes($filter, $view->param('filter/s_typecode', array())); |
|
136 | 136 | |
137 | - $view->items = $cntl->searchItems( $filter, $total ); |
|
137 | + $view->items = $cntl->searchItems($filter, $total); |
|
138 | 138 | $view->total = $total; |
139 | 139 | |
140 | 140 | return $response; |