1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2025 |
6
|
|
|
* @package Admin |
7
|
|
|
* @subpackage JsonAdm |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JsonAdm\Service\Config; |
12
|
|
|
|
13
|
|
|
use \Psr\Http\Message\ServerRequestInterface; |
|
|
|
|
14
|
|
|
use \Psr\Http\Message\ResponseInterface; |
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* JSON API service config client |
19
|
|
|
* |
20
|
|
|
* @package Admin |
21
|
|
|
* @subpackage JsonAdm |
22
|
|
|
*/ |
23
|
|
|
class Standard |
24
|
|
|
extends \Aimeos\Admin\JsonAdm\Standard |
25
|
|
|
implements \Aimeos\Admin\JsonAdm\Common\Iface |
26
|
|
|
{ |
27
|
|
|
/** admin/jsonadm/service/config/decorators/excludes |
28
|
|
|
* Excludes decorators added by the "common" option from the JSON API clients |
29
|
|
|
* |
30
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
31
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
32
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
33
|
|
|
* modify what is returned to the caller. |
34
|
|
|
* |
35
|
|
|
* This option allows you to remove a decorator added via |
36
|
|
|
* "admin/jsonadm/common/decorators/default" before they are wrapped |
37
|
|
|
* around the Jsonadm client. |
38
|
|
|
* |
39
|
|
|
* admin/jsonadm/decorators/excludes = array( 'decorator1' ) |
40
|
|
|
* |
41
|
|
|
* This would remove the decorator named "decorator1" from the list of |
42
|
|
|
* common decorators ("\Aimeos\Admin\JsonAdm\Common\Decorator\*") added via |
43
|
|
|
* "admin/jsonadm/common/decorators/default" for the JSON API client. |
44
|
|
|
* |
45
|
|
|
* @param array List of decorator names |
46
|
|
|
* @since 2017.07 |
47
|
|
|
* @category Developer |
48
|
|
|
* @see admin/jsonadm/common/decorators/default |
49
|
|
|
* @see admin/jsonadm/service/config/decorators/global |
50
|
|
|
* @see admin/jsonadm/service/config/decorators/local |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
/** admin/jsonadm/service/config/decorators/global |
54
|
|
|
* Adds a list of globally available decorators only to the Jsonadm client |
55
|
|
|
* |
56
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
57
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
58
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
59
|
|
|
* modify what is returned to the caller. |
60
|
|
|
* |
61
|
|
|
* This option allows you to wrap global decorators |
62
|
|
|
* ("\Aimeos\Admin\Jsonadm\Common\Decorator\*") around the Jsonadm |
63
|
|
|
* client. |
64
|
|
|
* |
65
|
|
|
* admin/jsonadm/service/config/decorators/global = array( 'decorator1' ) |
66
|
|
|
* |
67
|
|
|
* This would add the decorator named "decorator1" defined by |
68
|
|
|
* "\Aimeos\Admin\Jsonadm\Common\Decorator\Decorator1" only to the |
69
|
|
|
* "service/config" Jsonadm client. |
70
|
|
|
* |
71
|
|
|
* @param array List of decorator names |
72
|
|
|
* @since 2017.07 |
73
|
|
|
* @category Developer |
74
|
|
|
* @see admin/jsonadm/common/decorators/default |
75
|
|
|
* @see admin/jsonadm/service/config/decorators/excludes |
76
|
|
|
* @see admin/jsonadm/service/config/decorators/local |
77
|
|
|
*/ |
78
|
|
|
|
79
|
|
|
/** admin/jsonadm/service/config/decorators/local |
80
|
|
|
* Adds a list of local decorators only to the Jsonadm client |
81
|
|
|
* |
82
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
83
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
84
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
85
|
|
|
* modify what is returned to the caller. |
86
|
|
|
* |
87
|
|
|
* This option allows you to wrap local decorators |
88
|
|
|
* ("\Aimeos\Admin\Jsonadm\Service\Config\Decorator\*") around the Jsonadm |
89
|
|
|
* client. |
90
|
|
|
* |
91
|
|
|
* admin/jsonadm/service/config/decorators/local = array( 'decorator2' ) |
92
|
|
|
* |
93
|
|
|
* This would add the decorator named "decorator2" defined by |
94
|
|
|
* "\Aimeos\Admin\Jsonadm\Service\Config\Decorator\Decorator2" only to the |
95
|
|
|
* "service/config" Jsonadm client. |
96
|
|
|
* |
97
|
|
|
* @param array List of decorator names |
98
|
|
|
* @since 2017.07 |
99
|
|
|
* @category Developer |
100
|
|
|
* @see admin/jsonadm/common/decorators/default |
101
|
|
|
* @see admin/jsonadm/service/config/decorators/excludes |
102
|
|
|
* @see admin/jsonadm/service/config/decorators/global |
103
|
|
|
*/ |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Returns the requested resource or the resource list |
108
|
|
|
* |
109
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
110
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
111
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
112
|
|
|
*/ |
113
|
|
|
public function get( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
114
|
|
|
{ |
115
|
|
|
$view = $this->view(); |
116
|
|
|
|
117
|
|
|
try |
118
|
|
|
{ |
119
|
|
|
$response = $this->getItems( $view, $request, $response ); |
120
|
|
|
$status = 200; |
121
|
|
|
} |
122
|
|
|
catch( \Aimeos\MShop\Exception $e ) |
123
|
|
|
{ |
124
|
|
|
$status = 404; |
125
|
|
|
$view->errors = array( array( |
126
|
|
|
'title' => $this->context()->translate( 'mshop', $e->getMessage() ), |
127
|
|
|
'detail' => $e->getTraceAsString(), |
128
|
|
|
) ); |
129
|
|
|
} |
130
|
|
|
catch( \Exception $e ) |
131
|
|
|
{ |
132
|
|
|
$status = 500; |
133
|
|
|
$view->errors = array( array( |
134
|
|
|
'title' => $e->getMessage(), |
135
|
|
|
'detail' => $e->getTraceAsString(), |
136
|
|
|
) ); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** admin/jsonadm/service/config/template-get |
140
|
|
|
* Relative path to the JSON API template for GET requests |
141
|
|
|
* |
142
|
|
|
* The template file contains the code and processing instructions |
143
|
|
|
* to generate the result shown in the JSON API body. The |
144
|
|
|
* configuration string is the path to the template file relative |
145
|
|
|
* to the templates directory (usually in templates/admin/jsonadm). |
146
|
|
|
* |
147
|
|
|
* You can overwrite the template file configuration in extensions and |
148
|
|
|
* provide alternative templates. These alternative templates should be |
149
|
|
|
* named like the default one but with the string "standard" replaced by |
150
|
|
|
* an unique name. You may use the name of your project for this. If |
151
|
|
|
* you've implemented an alternative client class as well, "standard" |
152
|
|
|
* should be replaced by the name of the new class. |
153
|
|
|
* |
154
|
|
|
* @param string Relative path to the template creating the body for the GET method of the JSON API |
155
|
|
|
* @since 2017.07 |
156
|
|
|
* @category Developer |
157
|
|
|
*/ |
158
|
|
|
$tplconf = 'admin/jsonadm/service/config/template-get'; |
159
|
|
|
$default = 'config'; |
160
|
|
|
|
161
|
|
|
$body = $view->render( $view->config( $tplconf, $default ) ); |
162
|
|
|
|
163
|
|
|
return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
164
|
|
|
->withBody( $view->response()->createStreamFromString( $body ) ) |
165
|
|
|
->withStatus( $status ); |
|
|
|
|
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Retrieves the item or items and adds the data to the view |
171
|
|
|
* |
172
|
|
|
* @param \Aimeos\Base\View\Iface $view View instance |
173
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
174
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
175
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
176
|
|
|
*/ |
177
|
|
|
protected function getItems( \Aimeos\Base\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
178
|
|
|
{ |
179
|
|
|
if( ( $id = $view->param( 'id' ) ) == null ) { |
180
|
|
|
throw new \Aimeos\Admin\JsonAdm\Exception( 'No ID given', 400 ); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
$manager = \Aimeos\MShop::create( $this->context(), 'service' ); |
184
|
|
|
$item = $manager->create()->setProvider( $id ); |
185
|
|
|
|
186
|
|
|
$view->configItems = $manager->getProvider( $item, $view->param( 'type', 'payment' ) )->getConfigBE(); |
187
|
|
|
|
188
|
|
|
return $response; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths