File tree 7 files changed +49
-10
lines changed
src/Symfony/Component/Notifier
7 files changed +49
-10
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ public function getOptions(): ?MessageOptionsInterface
77
77
/**
78
78
* @return $this
79
79
*/
80
- public function transport (?string $ transport ): MessageInterface
80
+ public function transport (?string $ transport ): self
81
81
{
82
82
$ this ->transport = $ transport ;
83
83
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ public function getOptions(): ?MessageOptionsInterface
102
102
/**
103
103
* @return $this
104
104
*/
105
- public function transport (string $ transport ): MessageInterface
105
+ public function transport (string $ transport ): self
106
106
{
107
107
if (!$ this ->message instanceof Email) {
108
108
throw new LogicException ('Cannot set a Transport on a RawMessage instance. ' );
Original file line number Diff line number Diff line change @@ -25,6 +25,4 @@ public function getSubject(): string;
25
25
public function getOptions (): ?MessageOptionsInterface ;
26
26
27
27
public function getTransport (): ?string ;
28
-
29
- public function transport (string $ transport ): self ;
30
28
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace Symfony \Component \Notifier \Message ;
15
+
16
+ final class NullMessage implements MessageInterface
17
+ {
18
+ private $ decoratedMessage ;
19
+
20
+ public function __construct (MessageInterface $ message )
21
+ {
22
+ $ this ->decoratedMessage = $ message ;
23
+ }
24
+
25
+ public function getRecipientId (): ?string
26
+ {
27
+ return $ this ->decoratedMessage ->getRecipientId ();
28
+ }
29
+
30
+ public function getSubject (): string
31
+ {
32
+ return $ this ->decoratedMessage ->getSubject ();
33
+ }
34
+
35
+ public function getOptions (): ?MessageOptionsInterface
36
+ {
37
+ return $ this ->decoratedMessage ->getOptions ();
38
+ }
39
+
40
+ public function getTransport (): ?string
41
+ {
42
+ return $ this ->decoratedMessage ->getTransport () ?? 'null ' ;
43
+ }
44
+ }
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public function getSubject(): string
83
83
/**
84
84
* @return $this
85
85
*/
86
- public function transport (string $ transport ): MessageInterface
86
+ public function transport (string $ transport ): self
87
87
{
88
88
$ this ->transport = $ transport ;
89
89
Original file line number Diff line number Diff line change 15
15
use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
16
16
use Symfony \Component \Notifier \Event \MessageEvent ;
17
17
use Symfony \Component \Notifier \Message \MessageInterface ;
18
+ use Symfony \Component \Notifier \Message \NullMessage ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
19
20
use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
20
21
@@ -34,9 +35,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null)
34
35
35
36
public function send (MessageInterface $ message ): SentMessage
36
37
{
37
- if (null === $ message ->getTransport ()) {
38
- $ message ->transport ((string ) $ this );
39
- }
38
+ $ message = new NullMessage ($ message );
40
39
41
40
if (null !== $ this ->dispatcher ) {
42
41
$ this ->dispatcher ->dispatch (new MessageEvent ($ message ));
Original file line number Diff line number Diff line change @@ -57,8 +57,6 @@ public function send(MessageInterface $message): SentMessage
57
57
if (!$ transport = $ message ->getTransport ()) {
58
58
foreach ($ this ->transports as $ transportName => $ transport ) {
59
59
if ($ transport ->supports ($ message )) {
60
- $ message ->transport ($ transportName );
61
-
62
60
return $ transport ->send ($ message );
63
61
}
64
62
}
You can’t perform that action at this time.
0 commit comments