-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
NullTransport.php
49 lines (41 loc) · 1.19 KB
/
NullTransport.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
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 <fabien@symfony.com>
*
* @experimental in 5.0
*/
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
{
return 'null';
}
public function supports(MessageInterface $message): bool
{
return true;
}
}