8
8
9
9
namespace Magento \AsynchronousOperations \Model ;
10
10
11
- use Magento \Framework \Serialize \Serializer \Json ;
12
11
use Magento \AsynchronousOperations \Api \Data \OperationInterface ;
13
- use Magento \Framework \Bulk \OperationManagementInterface ;
14
12
use 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 ;
22
15
use Magento \Framework \DB \Adapter \ConnectionException ;
23
16
use Magento \Framework \DB \Adapter \DeadlockException ;
24
17
use 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 ;
25
24
use Magento \Framework \Webapi \ServiceOutputProcessor ;
26
- use Magento \ Framework \ Communication \ ConfigInterface as CommunicationConfig ;
25
+ use Psr \ Log \ LoggerInterface ;
27
26
28
27
/**
29
- * Class OperationProcessor
28
+ * Proccess operation
30
29
*
31
30
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
32
31
*/
@@ -80,9 +79,9 @@ class OperationProcessor
80
79
* @param ConsumerConfigurationInterface $configuration
81
80
* @param Json $jsonHelper
82
81
* @param OperationManagementInterface $operationManagement
83
- * @param LoggerInterface $logger
84
82
* @param \Magento\Framework\Webapi\ServiceOutputProcessor $serviceOutputProcessor
85
83
* @param \Magento\Framework\Communication\ConfigInterface $communicationConfig
84
+ * @param LoggerInterface $logger
86
85
*/
87
86
public function __construct (
88
87
MessageValidator $ messageValidator ,
@@ -137,7 +136,9 @@ public function process(string $encodedMessage)
137
136
$ result = $ this ->executeHandler ($ callback , $ entityParams );
138
137
$ status = $ result ['status ' ];
139
138
$ errorCode = $ result ['error_code ' ];
139
+ // phpcs:disable Magento2.Performance.ForeachArrayMerge
140
140
$ messages = array_merge ($ messages , $ result ['messages ' ]);
141
+ // phpcs:enable Magento2.Performance.ForeachArrayMerge
141
142
$ outputData = $ result ['output_data ' ];
142
143
}
143
144
}
@@ -174,8 +175,8 @@ public function process(string $encodedMessage)
174
175
/**
175
176
* Execute topic handler
176
177
*
177
- * @param $callback
178
- * @param $entityParams
178
+ * @param callable $callback
179
+ * @param array $entityParams
179
180
* @return array
180
181
*/
181
182
private function executeHandler ($ callback , $ entityParams )
@@ -187,7 +188,9 @@ private function executeHandler($callback, $entityParams)
187
188
'output_data ' => null
188
189
];
189
190
try {
191
+ // phpcs:disable Magento2.Functions.DiscouragedFunction
190
192
$ result ['output_data ' ] = call_user_func_array ($ callback , $ entityParams );
193
+ // phpcs:enable Magento2.Functions.DiscouragedFunction
191
194
$ result ['messages ' ][] = sprintf ('Service execution success %s::%s ' , get_class ($ callback [0 ]), $ callback [1 ]);
192
195
} catch (\Zend_Db_Adapter_Exception $ e ) {
193
196
$ this ->logger ->critical ($ e ->getMessage ());
@@ -206,9 +209,7 @@ private function executeHandler($callback, $entityParams)
206
209
}
207
210
} catch (NoSuchEntityException $ e ) {
208
211
$ 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 ;
212
213
$ result ['error_code ' ] = $ e ->getCode ();
213
214
$ result ['messages ' ][] = $ e ->getMessage ();
214
215
} catch (LocalizedException $ e ) {
0 commit comments