File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Component \Notifier \Transport ;
1313
14+ use Symfony \Component \EventDispatcher \Event ;
15+ use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
16+ use Symfony \Component \Notifier \Event \MessageEvent ;
1417use Symfony \Component \Notifier \Message \MessageInterface ;
18+ use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
1519
1620/**
1721 * @author Fabien Potencier <fabien@symfony.com>
2024 */
2125class NullTransport implements TransportInterface
2226{
27+ private $ dispatcher ;
28+
29+ public function __construct (EventDispatcherInterface $ dispatcher = null )
30+ {
31+ $ this ->dispatcher = class_exists (Event::class) ? LegacyEventDispatcherProxy::decorate ($ dispatcher ) : $ dispatcher ;
32+ }
33+
2334 public function send (MessageInterface $ message ): void
2435 {
36+ if (null !== $ this ->dispatcher ) {
37+ $ this ->dispatcher ->dispatch (new MessageEvent ($ message ));
38+ }
2539 }
2640
2741 public function __toString (): string
Original file line number Diff line number Diff 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 ());
You can’t perform that action at this time.
0 commit comments