8000 [Notifier] Dispatch message event in null transport · symfony/symfony@3809d90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3809d90

Browse files
committed
[Notifier] Dispatch message event in null transport
1 parent de15900 commit 3809d90

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/Notifier/Transport/NullTransport.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Symfony\Component\Notifier\Transport;
1313

14+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
15+
use Symfony\Component\Notifier\Event\MessageEvent;
1416
use Symfony\Component\Notifier\Message\MessageInterface;
17+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1518

1619
/**
1720
* @author Fabien Potencier <fabien@symfony.com>
@@ -20,8 +23,18 @@
2023
*/
2124
class NullTransport implements TransportInterface
2225
{
26+
private $dispatcher;
27+
28+
public function __construct(EventDispatcherInterface $dispatcher = null)
29+
{
30+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
31+
}
32+
2333
public function send(MessageInterface $message): void
2434
{
35+
if (null !== $this->dispatcher) {
36+
$this->dispatcher->dispatch(new MessageEvent($message));
37+
}
2538
}
2639

2740
public function __toString(): string

src/Symfony/Component/Notifier/Transport/NullTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class NullTransportFactory extends AbstractTransportFactory
2626
public function create(Dsn $dsn): TransportInterface
2727
{
2828
if ('null' === $dsn->getScheme()) {
29-
return new NullTransport();
29+
return new NullTransport($this->dispatcher);
3030
}
3131

3232
throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());

0 commit comments

Comments
 (0)
0