1717use Magento \Framework \Reflection \DataObjectProcessor ;
1818use Magento \AsynchronousOperations \Api \Data \AsyncResponseInterfaceFactory ;
1919use Magento \AsynchronousOperations \Api \Data \AsyncResponseInterface ;
20- use Magento \Framework \Webapi \Rest \Request ;
21- use Magento \Framework \Webapi \Exception ;
2220
2321/**
2422 * Responsible for dispatching single and bulk requests.
2725 */
2826class AsynchronousRequestProcessor implements RequestProcessorInterface
2927{
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.+)/ " ;
3230
3331 /**
3432 * @var \Magento\Framework\Webapi\Rest\Response
@@ -89,9 +87,9 @@ public function __construct(
8987 }
9088
9189 /**
92- * @inheritdoc
90+ * { @inheritdoc}
9391 */
94- public function process (Request $ request )
92+ public function process (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
9593 {
9694 $ path = $ request ->getPathInfo ();
9795 $ path = preg_replace ($ this ->processorPath , "$1 " , $ path );
@@ -121,10 +119,7 @@ public function process(Request $request)
121119 }
122120
123121 /**
124- * Get topic name from webapi_async_config services config array by route url and http method
125- *
126122 * @param \Magento\Framework\Webapi\Rest\Request $request
127- *
128123 * @return string
129124 */
130125 private function getTopicName ($ request )
@@ -138,58 +133,29 @@ private function getTopicName($request)
138133 }
139134
140135 /**
141- * @inheritdoc
136+ * { @inheritdoc}
142137 */
143- public function canProcess (Request $ request )
138+ public function canProcess (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
144139 {
145- if ($ request ->getHttpMethod () === Request::HTTP_METHOD_GET ) {
140+ if ($ request ->getHttpMethod () === \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_GET ) {
146141 return false ;
147142 }
148143
149144 if (preg_match ($ this ->processorPath , $ request ->getPathInfo ()) === 1 ) {
150- return $ this -> checkSelfResourceRequest ( $ request ) ;
145+ return true ;
151146 }
152-
153147 return false ;
154148 }
155149
156150 /**
157- * Check if current request is bulk request
158- *
159- * @param Request $request
151+ * @param \Magento\Framework\Webapi\Rest\Request $request
160152 * @return bool
161153 */
162- public function isBulk (Request $ request )
154+ public function isBulk (\ Magento \ Framework \ Webapi \ Rest \ Request $ request )
163155 {
164156 if (preg_match (self ::BULK_PROCESSOR_PATH , $ request ->getPathInfo ()) === 1 ) {
165157 return true ;
166158 }
167159 return false ;
168160 }
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- }
195161}
0 commit comments