17
17
use Magento \Framework \Reflection \DataObjectProcessor ;
18
18
use Magento \AsynchronousOperations \Api \Data \AsyncResponseInterfaceFactory ;
19
19
use Magento \AsynchronousOperations \Api \Data \AsyncResponseInterface ;
20
- use Magento \Framework \Webapi \Rest \Request ;
21
- use Magento \Framework \Webapi \Exception ;
22
20
23
21
/**
24
22
* Responsible for dispatching single and bulk requests.
27
25
*/
28
26
class AsynchronousRequestProcessor implements RequestProcessorInterface
29
27
{
30
- public const PROCESSOR_PATH = "/^ \\/async( \\/V.+)/ " ;
31
- public const BULK_PROCESSOR_PATH = "/^ \\/async\/bulk( \\/V.+)/ " ;
28
+ const PROCESSOR_PATH = "/^ \\/async( \\/V.+)/ " ;
29
+ const BULK_PROCESSOR_PATH = "/^ \\/async\/bulk( \\/V.+)/ " ;
32
30
33
31
/**
34
32
* @var \Magento\Framework\Webapi\Rest\Response
@@ -89,9 +87,9 @@ public function __construct(
89
87
}
90
88
91
89
/**
92
- * @inheritdoc
90
+ * { @inheritdoc}
93
91
*/
94
- public function process (Request $ request )
92
+ public function process (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
95
93
{
96
94
$ path = $ request ->getPathInfo ();
97
95
$ path = preg_replace ($ this ->processorPath , "$1 " , $ path );
@@ -121,10 +119,7 @@ public function process(Request $request)
121
119
}
122
120
123
121
/**
124
- * Get topic name from webapi_async_config services config array by route url and http method
125
- *
126
122
* @param \Magento\Framework\Webapi\Rest\Request $request
127
- *
128
123
* @return string
129
124
*/
130
125
private function getTopicName ($ request )
@@ -138,58 +133,29 @@ private function getTopicName($request)
138
133
}
139
134
140
135
/**
141
- * @inheritdoc
136
+ * { @inheritdoc}
142
137
*/
143
- public function canProcess (Request $ request )
138
+ public function canProcess (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
144
139
{
145
- if ($ request ->getHttpMethod () === Request::HTTP_METHOD_GET ) {
140
+ if ($ request ->getHttpMethod () === \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_GET ) {
146
141
return false ;
147
142
}
148
143
149
144
if (preg_match ($ this ->processorPath , $ request ->getPathInfo ()) === 1 ) {
150
- return $ this -> checkSelfResourceRequest ( $ request ) ;
145
+ return true ;
151
146
}
152
-
153
147
return false ;
154
148
}
155
149
156
150
/**
157
- * Check if current request is bulk request
158
- *
159
- * @param Request $request
151
+ * @param \Magento\Framework\Webapi\Rest\Request $request
160
152
* @return bool
161
153
*/
162
- public function isBulk (Request $ request )
154
+ public function isBulk (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
163
155
{
164
156
if (preg_match (self ::BULK_PROCESSOR_PATH , $ request ->getPathInfo ()) === 1 ) {
165
157
return true ;
166
158
}
167
159
return false ;
168
160
}
169
-
170
- /**
171
- * Check if current request is self resource request
172
- *
173
- * @param Request $request
174
- * @return bool
175
- *
176
- * @throws Exception
177
- */
178
- private function checkSelfResourceRequest (Request $ request ): bool
179
- {
180
- $ path = preg_replace ($ this ->processorPath , "$1 " , $ request ->getPathInfo ());
181
- $ request ->setPathInfo (
182
- $ path
183
- );
184
-
185
- $ route = $ this ->inputParamsResolver ->getRoute ();
186
- $ aclResources = $ route ->getAclResources ();
187
-
188
- // We do not process self resource requests asynchronously
189
- if (in_array ('self ' , $ aclResources , true )) {
190
- return false ;
191
- }
192
-
193
- return true ;
194
- }
195
161
}
0 commit comments