88
99namespace Magento \AsynchronousOperations \Model ;
1010
11- use Magento \Framework \Serialize \Serializer \Json ;
1211use Magento \AsynchronousOperations \Api \Data \OperationInterface ;
13- use Magento \Framework \Bulk \OperationManagementInterface ;
1412use Magento \AsynchronousOperations \Model \ConfigInterface as AsyncConfig ;
15- use Magento \Framework \MessageQueue \MessageValidator ;
16- use Magento \Framework \MessageQueue \MessageEncoder ;
17- use Magento \Framework \Exception \NoSuchEntityException ;
18- use Magento \Framework \MessageQueue \ConsumerConfigurationInterface ;
19- use Psr \Log \LoggerInterface ;
20- use Magento \Framework \Exception \LocalizedException ;
21- use Magento \Framework \Exception \TemporaryStateExceptionInterface ;
13+ use Magento \Framework \Bulk \OperationManagementInterface ;
14+ use Magento \Framework \Communication \ConfigInterface as CommunicationConfig ;
2215use Magento \Framework \DB \Adapter \ConnectionException ;
2316use Magento \Framework \DB \Adapter \DeadlockException ;
2417use Magento \Framework \DB \Adapter \LockWaitException ;
18+ use Magento \Framework \Exception \LocalizedException ;
19+ use Magento \Framework \Exception \NoSuchEntityException ;
20+ use Magento \Framework \MessageQueue \ConsumerConfigurationInterface ;
21+ use Magento \Framework \MessageQueue \MessageEncoder ;
22+ use Magento \Framework \MessageQueue \MessageValidator ;
23+ use Magento \Framework \Serialize \Serializer \Json ;
2524use Magento \Framework \Webapi \ServiceOutputProcessor ;
26- use Magento \ Framework \ Communication \ ConfigInterface as CommunicationConfig ;
25+ use Psr \ Log \ LoggerInterface ;
2726
2827/**
29- * Class OperationProcessor
28+ * Proccess operation
3029 *
3130 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3231 */
@@ -80,9 +79,9 @@ class OperationProcessor
8079 * @param ConsumerConfigurationInterface $configuration
8180 * @param Json $jsonHelper
8281 * @param OperationManagementInterface $operationManagement
83- * @param LoggerInterface $logger
8482 * @param \Magento\Framework\Webapi\ServiceOutputProcessor $serviceOutputProcessor
8583 * @param \Magento\Framework\Communication\ConfigInterface $communicationConfig
84+ * @param LoggerInterface $logger
8685 */
8786 public function __construct (
8887 MessageValidator $ messageValidator ,
@@ -137,7 +136,9 @@ public function process(string $encodedMessage)
137136 $ result = $ this ->executeHandler ($ callback , $ entityParams );
138137 $ status = $ result ['status ' ];
139138 $ errorCode = $ result ['error_code ' ];
139+ // phpcs:disable Magento2.Performance.ForeachArrayMerge
140140 $ messages = array_merge ($ messages , $ result ['messages ' ]);
141+ // phpcs:enable Magento2.Performance.ForeachArrayMerge
141142 $ outputData = $ result ['output_data ' ];
142143 }
143144 }
@@ -174,8 +175,8 @@ public function process(string $encodedMessage)
174175 /**
175176 * Execute topic handler
176177 *
177- * @param $callback
178- * @param $entityParams
178+ * @param callable $callback
179+ * @param array $entityParams
179180 * @return array
180181 */
181182 private function executeHandler ($ callback , $ entityParams )
@@ -187,7 +188,9 @@ private function executeHandler($callback, $entityParams)
187188 'output_data ' => null
188189 ];
189190 try {
191+ // phpcs:disable Magento2.Functions.DiscouragedFunction
190192 $ result ['output_data ' ] = call_user_func_array ($ callback , $ entityParams );
193+ // phpcs:enable Magento2.Functions.DiscouragedFunction
191194 $ result ['messages ' ][] = sprintf ('Service execution success %s::%s ' , get_class ($ callback [0 ]), $ callback [1 ]);
192195 } catch (\Zend_Db_Adapter_Exception $ e ) {
193196 $ this ->logger ->critical ($ e ->getMessage ());
@@ -206,9 +209,7 @@ private function executeHandler($callback, $entityParams)
206209 }
207210 } catch (NoSuchEntityException $ e ) {
208211 $ this ->logger ->error ($ e ->getMessage ());
209- $ result ['status ' ] = ($ e instanceof TemporaryStateExceptionInterface) ?
210- OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED :
211- OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED ;
212+ $ result ['status ' ] = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED ;
212213 $ result ['error_code ' ] = $ e ->getCode ();
213214 $ result ['messages ' ][] = $ e ->getMessage ();
214215 } catch (LocalizedException $ e ) {
0 commit comments