Skip to content

Commit fea3cf8

Browse files
committed
Fixed BIC for Magento\Framework\MessageQueue\Rpc\Publisher
1 parent b4cbd4c commit fea3cf8

File tree

1 file changed

+28
-42
lines changed

1 file changed

+28
-42
lines changed

lib/internal/Magento/Framework/MessageQueue/Rpc/Publisher.php

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\MessageQueue\Rpc;
78

8-
use Magento\Framework\MessageQueue\PublisherInterface;
9+
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\MessageQueue\EnvelopeFactory;
1011
use Magento\Framework\MessageQueue\ExchangeRepository;
1112
use Magento\Framework\MessageQueue\MessageEncoder;
1213
use Magento\Framework\MessageQueue\MessageValidator;
1314
use Magento\Framework\MessageQueue\Publisher\ConfigInterface as PublisherConfig;
15+
use Magento\Framework\MessageQueue\PublisherInterface;
1416

1517
/**
1618
* A MessageQueue Publisher to handle publishing a message.
@@ -49,27 +51,42 @@ class Publisher implements PublisherInterface
4951
*/
5052
private $publisherConfig;
5153

52-
//@codingStandardsIgnoreStart
5354
/**
5455
* Initialize dependencies.
5556
*
5657
* @param ExchangeRepository $exchangeRepository
5758
* @param EnvelopeFactory $envelopeFactory
58-
* @param MessageEncoder $messageEncoder
59-
* @param MessageValidator $messageValidator
59+
* @param null $messageQueueConfig @deprecated obsolete dependency
60+
* @param null $amqpConfig @deprecated obsolete dependency
61+
* @param MessageEncoder|null $messageEncoder
62+
* @param MessageValidator|null $messageValidator
63+
* @param ResponseQueueNameBuilder|null $responseQueueNameBuilder
64+
* @param PublisherConfig|null $publisherConfig
65+
*
66+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6067
*/
6168
public function __construct(
6269
ExchangeRepository $exchangeRepository,
6370
EnvelopeFactory $envelopeFactory,
64-
MessageEncoder $messageEncoder,
65-
MessageValidator $messageValidator
71+
$messageQueueConfig = null,
72+
$amqpConfig = null,
73+
MessageEncoder $messageEncoder = null,
74+
MessageValidator $messageValidator = null,
75+
ResponseQueueNameBuilder $responseQueueNameBuilder = null,
76+
PublisherConfig $publisherConfig = null
6677
) {
6778
$this->exchangeRepository = $exchangeRepository;
6879
$this->envelopeFactory = $envelopeFactory;
69-
$this->messageEncoder = $messageEncoder;
70-
$this->messageValidator = $messageValidator;
80+
$objectManager = ObjectManager::getInstance();
81+
$this->messageEncoder = $messageEncoder
82+
?? $objectManager->get(MessageEncoder::class);
83+
$this->messageValidator = $messageValidator
84+
?? $objectManager->get(MessageValidator::class);
85+
$this->responseQueueNameBuilder = $responseQueueNameBuilder
86+
?? $objectManager->get(ResponseQueueNameBuilder::class);
87+
$this->publisherConfig = $publisherConfig
88+
?? $objectManager->get(PublisherConfig::class);
7189
}
72-
//@codingStandardsIgnoreEnd
7390

7491
/**
7592
* @inheritdoc
@@ -78,7 +95,7 @@ public function publish($topicName, $data)
7895
{
7996
$this->messageValidator->validate($topicName, $data);
8097
$data = $this->messageEncoder->encode($topicName, $data);
81-
$replyTo = $this->getResponseQueueNameBuilder()->getQueueName($topicName);
98+
$replyTo = $this->responseQueueNameBuilder->getQueueName($topicName);
8299
$envelope = $this->envelopeFactory->create(
83100
[
84101
'body' => $data,
@@ -92,40 +109,9 @@ public function publish($topicName, $data)
92109
]
93110
]
94111
);
95-
$connectionName = $this->getPublisherConfig()->getPublisher($topicName)->getConnection()->getName();
112+
$connectionName = $this->publisherConfig->getPublisher($topicName)->getConnection()->getName();
96113
$exchange = $this->exchangeRepository->getByConnectionName($connectionName);
97114
$responseMessage = $exchange->enqueue($topicName, $envelope);
98115
return $this->messageEncoder->decode($topicName, $responseMessage, false);
99116
}
100-
101-
/**
102-
* Get response queue name builder.
103-
*
104-
* @return ResponseQueueNameBuilder
105-
*
106-
* @deprecated 103.0.0
107-
*/
108-
private function getResponseQueueNameBuilder()
109-
{
110-
if ($this->responseQueueNameBuilder === null) {
111-
$this->responseQueueNameBuilder = \Magento\Framework\App\ObjectManager::getInstance()
112-
->get(ResponseQueueNameBuilder::class);
113-
}
114-
return $this->responseQueueNameBuilder;
115-
}
116-
117-
/**
118-
* Get publisher config.
119-
*
120-
* @return PublisherConfig
121-
*
122-
* @deprecated 103.0.0
123-
*/
124-
private function getPublisherConfig()
125-
{
126-
if ($this->publisherConfig === null) {
127-
$this->publisherConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(PublisherConfig::class);
128-
}
129-
return $this->publisherConfig;
130-
}
131117
}

0 commit comments

Comments
 (0)