Skip to content

Commit 6d17185

Browse files
committed
changed event class name
1 parent c3fa2d4 commit 6d17185

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,4 +706,4 @@ Mail::to($request->user())->send(new OrderShipped($order));
706706
<a name="events"></a>
707707
## 事件
708708

709-
在发送邮件消息的时候,组件会触发两个事件。`MessageSending` 事件在发送消息前触发,`MessageSent` 事件在消息发送完成后触发。记住,这些事件都是在邮件被**发送**时触发,而不是在队列化的时候。
709+
在发送邮件消息的时候,组件会触发两个事件。`MailMessageSending` 事件在发送消息前触发,`MailMessageSent` 事件在消息发送完成后触发。记住,这些事件都是在邮件被**发送**时触发,而不是在队列化的时候。

src/Events/MessageSending.php renamed to src/Events/MailMessageSending.php

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

1313
use Swift_Message;
1414

15-
class MessageSending
15+
class MailMessageSending
1616
{
1717
/**
1818
* The Swift message instance.

src/Events/MessageSent.php renamed to src/Events/MailMessageSent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Swift_Attachment;
1414
use Swift_Message;
1515

16-
class MessageSent
16+
class MailMessageSent
1717
{
1818
/**
1919
* The Swift message instance.

src/Mailer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use HyperfExt\Mail\Concerns\PendingMailable;
1616
use HyperfExt\Mail\Contracts\MailableInterface;
1717
use HyperfExt\Mail\Contracts\MailerInterface;
18-
use HyperfExt\Mail\Events\MessageSending;
19-
use HyperfExt\Mail\Events\MessageSent;
18+
use HyperfExt\Mail\Events\MailMessageSending;
19+
use HyperfExt\Mail\Events\MailMessageSent;
2020
use Psr\Container\ContainerInterface;
2121
use Psr\EventDispatcher\EventDispatcherInterface;
2222
use Swift_Mailer;
@@ -178,11 +178,11 @@ public function sendNow(MailableInterface $mailable): ?array
178178
// its recipients. We will then fire the sent event for the sent message.
179179
$swiftMessage = $message->getSwiftMessage();
180180

181-
$this->eventDispatcher->dispatch(new MessageSending($swiftMessage, $data));
181+
$this->eventDispatcher->dispatch(new MailMessageSending($swiftMessage, $data));
182182

183183
$this->sendSwiftMessage($swiftMessage, $failedRecipients);
184184

185-
$this->eventDispatcher->dispatch(new MessageSent($swiftMessage, $data));
185+
$this->eventDispatcher->dispatch(new MailMessageSent($swiftMessage, $data));
186186

187187
return $failedRecipients;
188188
}

tests/MailMailerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
use Hyperf\Utils\ApplicationContext;
1414
use HyperfExt\Mail\Contracts\MailableInterface;
15-
use HyperfExt\Mail\Events\MessageSending;
16-
use HyperfExt\Mail\Events\MessageSent;
15+
use HyperfExt\Mail\Events\MailMessageSending;
16+
use HyperfExt\Mail\Events\MailMessageSent;
1717
use HyperfExt\Mail\Mailer;
1818
use Mockery as m;
1919
use PHPUnit\Framework\TestCase;
@@ -39,8 +39,8 @@ public function testGlobalFromIsRespectedOnAllMessages()
3939
$mailable = m::mock(MailableInterface::class);
4040
$mailable->shouldReceive('handler')->once()->andReturn(null);
4141
$events = ApplicationContext::getContainer()->get(EventDispatcherInterface::class);
42-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSending::class));
43-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSent::class));
42+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSending::class));
43+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSent::class));
4444
$mailer = $this->getMailer();
4545
$this->setSwiftMailer($mailer);
4646
$mailer->setAlwaysFrom('[email protected]', 'Taylor Otwell');
@@ -56,8 +56,8 @@ public function testGlobalReturnPathIsRespectedOnAllMessages()
5656
$mailable = m::mock(MailableInterface::class);
5757
$mailable->shouldReceive('handler')->once()->andReturn(null);
5858
$events = ApplicationContext::getContainer()->get(EventDispatcherInterface::class);
59-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSending::class));
60-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSent::class));
59+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSending::class));
60+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSent::class));
6161
$mailer = $this->getMailer();
6262
$this->setSwiftMailer($mailer);
6363
$mailer->setAlwaysReturnPath('[email protected]');
@@ -73,8 +73,8 @@ public function testFailedRecipientsAreAppendedAndCanBeRetrieved()
7373
$mailable = m::mock(MailableInterface::class);
7474
$mailable->shouldReceive('handler')->once()->andReturn(null);
7575
$events = ApplicationContext::getContainer()->get(EventDispatcherInterface::class);
76-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSending::class));
77-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSent::class));
76+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSending::class));
77+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSent::class));
7878
$mailer = $this->getMailer();
7979
$mailer->getSwiftMailer()->shouldReceive('getTransport')->andReturn($transport = m::mock(Swift_Transport::class));
8080
$transport->shouldReceive('stop');
@@ -93,8 +93,8 @@ public function testEventsAreDispatched()
9393
$mailable = m::mock(MailableInterface::class);
9494
$mailable->shouldReceive('handler')->once()->andReturn(null);
9595
$events = ApplicationContext::getContainer()->get(EventDispatcherInterface::class);
96-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSending::class));
97-
$events->shouldReceive('dispatch')->once()->with(m::type(MessageSent::class));
96+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSending::class));
97+
$events->shouldReceive('dispatch')->once()->with(m::type(MailMessageSent::class));
9898
$mailer = $this->getMailer($events);
9999
$this->setSwiftMailer($mailer);
100100
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with(m::type(Swift_Message::class), []);

0 commit comments

Comments
 (0)