diff --git a/src/Symfony/Component/Notifier/Transport/NullTransport.php b/src/Symfony/Component/Notifier/Transport/NullTransport.php index 658243ae7d539..1754eeae891db 100644 --- a/src/Symfony/Component/Notifier/Transport/NullTransport.php +++ b/src/Symfony/Component/Notifier/Transport/NullTransport.php @@ -11,7 +11,10 @@ namespace Symfony\Component\Notifier\Transport; +use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; +use Symfony\Component\Notifier\Event\MessageEvent; use Symfony\Component\Notifier\Message\MessageInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * @author Fabien Potencier @@ -20,8 +23,18 @@ */ class NullTransport implements TransportInterface { + private $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher = null) + { + $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); + } + public function send(MessageInterface $message): void { + if (null !== $this->dispatcher) { + $this->dispatcher->dispatch(new MessageEvent($message)); + } } public function __toString(): string diff --git a/src/Symfony/Component/Notifier/Transport/NullTransportFactory.php b/src/Symfony/Component/Notifier/Transport/NullTransportFactory.php index abfcd1c75d3f7..196d052a05163 100644 --- a/src/Symfony/Component/Notifier/Transport/NullTransportFactory.php +++ b/src/Symfony/Component/Notifier/Transport/NullTransportFactory.php @@ -26,7 +26,7 @@ final class NullTransportFactory extends AbstractTransportFactory public function create(Dsn $dsn): TransportInterface { if ('null' === $dsn->getScheme()) { - return new NullTransport(); + return new NullTransport($this->dispatcher); } throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());