Skip to content

Commit e07a153

Browse files
Merge branch '5.0'
* 5.0: minor #35833 [FrameworkBundle] Add missing items in the unused tag pass whitelist (fabpot) [HttpClient][DX] Add URL context to JsonException messages [Routing] Improve localized routes performances [4.4][DoctrineBridge] Use new Types::* constants and support new json type [Validator] Add missing translations [Notifier] Dispatch message event in null transport [Messenger] Use Doctrine DBAL new Types::* constants
2 parents 1755348 + d41f424 commit e07a153

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Transport/NullTransport.php

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

1212
namespace Symfony\Component\Notifier\Transport;
1313

14+
use Symfony\Component\EventDispatcher\Event;
15+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
16+
use Symfony\Component\Notifier\Event\MessageEvent;
1417
use Symfony\Component\Notifier\Message\MessageInterface;
18+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1519

1620
/**
1721
* @author Fabien Potencier <fabien@symfony.com>
@@ -20,8 +24,18 @@
2024
*/
2125
class 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

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)