Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 51ac4d8

Browse files
committed
fix code related to reviewer comments and possible static-code test issues
1 parent 80732c8 commit 51ac4d8

File tree

7 files changed

+24
-32
lines changed

7 files changed

+24
-32
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
use PhpAmqpLib\Wire\AMQPTable;
1515
use Magento\Framework\Amqp\Queue;
1616
use Magento\Framework\MessageQueue\EnvelopeInterface;
17-
use Magento\AsynchronousOperations\Model\MassConsumerEnvelopeCallback;
17+
use Magento\AsynchronousOperations\Model\MassConsumerEnvelopeCallback as SubjectMassConsumerEnvelopeCallback;
1818
use Psr\Log\LoggerInterface;
1919

2020
/**
2121
* Plugin to get 'store_id' from the new custom header 'store_id' in amqp
2222
* 'application_headers' properties and setCurrentStore by value 'store_id'.
2323
*/
24-
class MassConsumerEnvelopeCallbackPlugin
24+
class MassConsumerEnvelopeCallback
2525
{
2626
/**
2727
* @var \Magento\Store\Model\StoreManagerInterface
@@ -52,12 +52,12 @@ public function __construct(
5252
}
5353

5454
/**
55-
* @param MassConsumerEnvelopeCallback $subject
55+
* @param SubjectMassConsumerEnvelopeCallback $subject
5656
* @param EnvelopeInterface $message
5757
* @return array|null
5858
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5959
*/
60-
public function beforeExecute(MassConsumerEnvelopeCallback $subject, EnvelopeInterface $message)
60+
public function beforeExecute(SubjectMassConsumerEnvelopeCallback $subject, EnvelopeInterface $message)
6161
{
6262
$amqpProperties = $message->getProperties();
6363
if (isset($amqpProperties['application_headers'])) {
@@ -76,7 +76,7 @@ public function beforeExecute(MassConsumerEnvelopeCallback $subject, EnvelopeInt
7676
return null;
7777
}
7878
if (isset($storeId) && $storeId !== $currentStoreId) {
79-
$this->storeManager->setCurrentStore($storeId);
79+
$this->storeManager->setCurrentStore($storeId);
8080
}
8181
}
8282
}

app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/ExchangePlugin.php renamed to app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
use Magento\Framework\MessageQueue\EnvelopeFactory;
1414
use PhpAmqpLib\Exception\AMQPInvalidArgumentException;
1515
use PhpAmqpLib\Wire\AMQPTable;
16-
use Magento\Framework\Amqp\Bulk\Exchange;
16+
use Magento\Framework\Amqp\Bulk\Exchange as SubjectExchange;
1717
use Magento\Framework\MessageQueue\EnvelopeInterface;
1818
use Psr\Log\LoggerInterface;
1919

2020
/**
2121
* Plugin to set 'store_id' to the new custom header 'store_id' in amqp
2222
* 'application_headers'.
2323
*/
24-
class ExchangePlugin
24+
class Exchange
2525
{
2626
/**
2727
* @var StoreManagerInterface
@@ -51,13 +51,13 @@ public function __construct(
5151
}
5252

5353
/**
54-
* @param Exchange $subject
54+
* @param SubjectExchange $subject
5555
* @param $topic
5656
* @param EnvelopeInterface[] $envelopes
5757
* @return array|null
5858
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5959
*/
60-
public function beforeEnqueue(Exchange $subject, $topic, array $envelopes)
60+
public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes)
6161
{
6262
try {
6363
$storeId = $this->storeManager->getStore()->getId();

app/code/Magento/AmqpStore/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"magento/framework": "*",
99
"magento/framework-amqp": "*",
1010
"magento/framework-message-queue": "*",
11+
"magento/module-store": "*",
1112
"php": "~7.1.3||~7.2.0"
1213
},
1314
"type": "magento2-module",

app/code/Magento/AmqpStore/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<type name="Magento\Framework\Amqp\Bulk\Exchange">
10-
<plugin name="amqpStoreIdFieldForAmqpBulkExchange" type="Magento\AmqpStore\Plugin\Framework\Amqp\Bulk\ExchangePlugin"/>
10+
<plugin name="amqpStoreIdFieldForAmqpBulkExchange" type="Magento\AmqpStore\Plugin\Framework\Amqp\Bulk\Exchange"/>
1111
</type>
1212
<type name="Magento\AsynchronousOperations\Model\MassConsumerEnvelopeCallback">
13-
<plugin name="amqpStoreIdFieldForAsynchronousOperationsMassConsumerEnvelopeCallback" type="Magento\AmqpStore\Plugin\AsynchronousOperations\MassConsumerEnvelopeCallbackPlugin"/>
13+
<plugin name="amqpStoreIdFieldForAsynchronousOperationsMassConsumerEnvelopeCallback" type="Magento\AmqpStore\Plugin\AsynchronousOperations\MassConsumerEnvelopeCallback"/>
1414
</type>
1515
</config>

app/code/Magento/AsynchronousOperations/Model/MassConsumer.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class MassConsumer implements ConsumerInterface
8080
* @param ConsumerConfigurationInterface $configuration
8181
* @param OperationProcessorFactory $operationProcessorFactory
8282
* @param LoggerInterface $logger
83-
* @param Registry $registry
8483
* @param MassConsumerEnvelopeCallbackFactory $massConsumerEnvelopeCallback
84+
* @param Registry $registry
8585
*/
8686
public function __construct(
8787
CallbackInvokerInterface $invoker,
@@ -90,8 +90,8 @@ public function __construct(
9090
ConsumerConfigurationInterface $configuration,
9191
OperationProcessorFactory $operationProcessorFactory,
9292
LoggerInterface $logger,
93-
Registry $registry = null,
94-
MassConsumerEnvelopeCallbackFactory $massConsumerEnvelopeCallback = null
93+
MassConsumerEnvelopeCallbackFactory $massConsumerEnvelopeCallback,
94+
Registry $registry = null
9595
) {
9696
$this->invoker = $invoker;
9797
$this->resource = $resource;
@@ -101,10 +101,9 @@ public function __construct(
101101
'configuration' => $configuration
102102
]);
103103
$this->logger = $logger;
104+
$this->massConsumerEnvelopeCallback = $massConsumerEnvelopeCallback;
104105
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
105106
->get(Registry::class);
106-
$this->massConsumerEnvelopeCallback = $massConsumerEnvelopeCallback ?? \Magento\Framework\App\ObjectManager::getInstance()
107-
->get(MassConsumerEnvelopeCallbackFactory::class);
108107
}
109108

110109
/**
@@ -135,12 +134,12 @@ private function getTransactionCallback(QueueInterface $queue)
135134
{
136135
$callbackInstance = $this->massConsumerEnvelopeCallback->create([
137136
'resource' => $this->resource,
138-
'messageController'=>$this->messageController,
139-
'configuration'=>$this->configuration,
140-
'operationProcessor'=>$this->operationProcessor,
141-
'logger'=>$this->logger,
142-
'registry'=>$this->registry,
143-
'queue'=>$queue,
137+
'messageController' => $this->messageController,
138+
'configuration' => $this->configuration,
139+
'operationProcessor' => $this->operationProcessor,
140+
'logger' => $this->logger,
141+
'registry' => $this->registry,
142+
'queue' => $queue,
144143
]);
145144
return function (EnvelopeInterface $message) use ($callbackInstance) {
146145
$callbackInstance->execute($message);

app/code/Magento/AsynchronousOperations/Model/MassConsumerEnvelopeCallback.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,21 @@ class MassConsumerEnvelopeCallback
5656
*/
5757
private $operationProcessor;
5858

59-
/**
60-
* @var Registry
61-
*/
62-
private $registry;
63-
6459
/**
6560
* @param ResourceConnection $resource
6661
* @param MessageController $messageController
6762
* @param ConsumerConfigurationInterface $configuration
6863
* @param OperationProcessorFactory $operationProcessorFactory
6964
* @param LoggerInterface $logger
7065
* @param QueueInterface $queue
71-
* @param Registry|null $registry
7266
*/
7367
public function __construct(
7468
ResourceConnection $resource,
7569
MessageController $messageController,
7670
ConsumerConfigurationInterface $configuration,
7771
OperationProcessorFactory $operationProcessorFactory,
7872
LoggerInterface $logger,
79-
QueueInterface $queue,
80-
Registry $registry = null
73+
QueueInterface $queue
8174
) {
8275
$this->resource = $resource;
8376
$this->messageController = $messageController;
@@ -86,8 +79,6 @@ public function __construct(
8679
'configuration' => $configuration
8780
]);
8881
$this->logger = $logger;
89-
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
90-
->get(Registry::class);
9182
$this->queue = $queue;
9283
}
9384

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"magento/module-admin-notification": "*",
102102
"magento/module-advanced-pricing-import-export": "*",
103103
"magento/module-amqp": "*",
104+
"magento/module-amqp-store": "*",
104105
"magento/module-analytics": "*",
105106
"magento/module-asynchronous-operations": "*",
106107
"magento/module-authorization": "*",

0 commit comments

Comments
 (0)