Skip to content

Commit 2c84a24

Browse files
committed
rename onPreDriverSend to onDriverPreSend. split getCommandOrTopic into two getters.
1 parent 6c0e31d commit 2c84a24

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

pkg/enqueue/Client/ChainExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function onPreSendCommand(PreSend $event): void
3131
}
3232
}
3333

34-
public function onPreDriverSend(PreDriverSend $context): void
34+
public function onDriverPreSend(DriverPreSend $context): void
3535
{
3636
foreach ($this->extensions as $extension) {
37-
$extension->onPreDriverSend($context);
37+
$extension->onDriverPreSend($context);
3838
}
3939
}
4040

pkg/enqueue/Client/ConsumptionExtension/ExclusiveCommandExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function onPreReceived(Context $context)
6464
public function onPreSendCommand(PreSend $context): void
6565
{
6666
$message = $context->getMessage();
67-
$command = $context->getCommandOrTopic();
67+
$command = $context->getCommand();
6868

6969
if (array_key_exists($command, $this->processorNameToQueueNameMap)) {
7070
$message->setProperty(Config::PARAMETER_PROCESSOR_NAME, $command);

pkg/enqueue/Client/PreDriverSend.php renamed to pkg/enqueue/Client/DriverPreSend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Enqueue\Client;
44

5-
class PreDriverSend
5+
class DriverPreSend
66
{
77
private $message;
88

pkg/enqueue/Client/EmptyExtensionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function onPreSendCommand(PreSend $context): void
1212
{
1313
}
1414

15-
public function onPreDriverSend(PreDriverSend $context): void
15+
public function onDriverPreSend(DriverPreSend $context): void
1616
{
1717
}
1818

pkg/enqueue/Client/ExtensionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public function onPreSendEvent(PreSend $context): void;
88

99
public function onPreSendCommand(PreSend $context): void;
1010

11-
public function onPreDriverSend(PreDriverSend $context): void;
11+
public function onDriverPreSend(DriverPreSend $context): void;
1212

1313
public function onPostSend(PostSend $context): void;
1414

pkg/enqueue/Client/PreSend.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,24 @@ public function __construct(
2828
$this->originalMessage = clone $message;
2929
}
3030

31-
public function getCommandOrTopic(): string
31+
public function getCommand(): string
3232
{
3333
return $this->commandOrTopic;
3434
}
3535

36-
public function changeCommandOrTopic(string $commandOrTopic): void
36+
public function getTopic(): string
3737
{
38-
$this->commandOrTopic = $commandOrTopic;
38+
return $this->commandOrTopic;
39+
}
40+
41+
public function changeCommand(string $newCommand): void
42+
{
43+
$this->commandOrTopic = $newCommand;
44+
}
45+
46+
public function changeTopic(string $newTopic): void
47+
{
48+
$this->commandOrTopic = $newTopic;
3949
}
4050

4151
public function changeBody($body, string $contentType = null): void

pkg/enqueue/Client/Producer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function sendEvent($topic, $message)
5151
$preSend = new PreSend($topic, $message, $this, $this->driver);
5252
$this->extension->onPreSendEvent($preSend);
5353

54-
$topic = $preSend->getCommandOrTopic();
54+
$topic = $preSend->getTopic();
5555
$message = $preSend->getMessage();
5656

5757
$message->setProperty(Config::PARAMETER_TOPIC_NAME, $topic);
@@ -68,7 +68,7 @@ public function sendCommand($command, $message, $needReply = false)
6868
$preSend = new PreSend($command, $message, $this, $this->driver);
6969
$this->extension->onPreSendEvent($preSend);
7070

71-
$command = $preSend->getCommandOrTopic();
71+
$command = $preSend->getCommand();
7272
$message = $preSend->getMessage();
7373

7474
$deleteReplyQueue = false;
@@ -137,7 +137,7 @@ private function doSend(Message $message)
137137
throw new \LogicException(sprintf('The %s property must not be set for messages that are sent to message bus.', Config::PARAMETER_PROCESSOR_NAME));
138138
}
139139

140-
$this->extension->onPreDriverSend(new PreDriverSend($message, $this, $this->driver));
140+
$this->extension->onPreDriverSend(new DriverPreSend($message, $this, $this->driver));
141141
$this->driver->sendToRouter($message);
142142
} elseif (Message::SCOPE_APP == $message->getScope()) {
143143
if (false == $message->getProperty(Config::PARAMETER_PROCESSOR_NAME)) {
@@ -147,7 +147,7 @@ private function doSend(Message $message)
147147
$message->setProperty(Config::PARAMETER_PROCESSOR_QUEUE_NAME, $this->driver->getConfig()->getRouterQueueName());
148148
}
149149

150-
$this->extension->onPreDriverSend(new PreDriverSend($message, $this, $this->driver));
150+
$this->extension->onPreDriverSend(new DriverPreSend($message, $this, $this->driver));
151151
$this->driver->sendToRouter($message);
152152
} else {
153153
throw new \LogicException(sprintf('The message scope "%s" is not supported.', $message->getScope()));

0 commit comments

Comments
 (0)