1 | <?php |
||
18 | abstract class AbstractAdapter implements AdapterInterface |
||
19 | { |
||
20 | /** |
||
21 | * The address used as a "from" address. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $fromAddress; |
||
26 | |||
27 | /** |
||
28 | * The name of the sender that belongs to the from address. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $fromName; |
||
33 | |||
34 | /** |
||
35 | * Sends a message over the transport. |
||
36 | * |
||
37 | * @param array $recipients A list with all recipients that should receive the message. |
||
38 | * @param Message $message The message to send. |
||
39 | * @param string $subject The subject for this message. |
||
40 | * @param string $text The plain text template. |
||
41 | * @param null|string $html The HTML template. |
||
42 | * @return void |
||
43 | */ |
||
44 | public function send(array $recipients, Message $message, string $subject, string $text, ?string $html): void |
||
45 | { |
||
46 | /** @var RecipientInterface $recipient */ |
||
47 | foreach ($recipients as $recipient) { |
||
48 | $this->sendToRecipient($recipient, $message, $subject, $text, $html); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Sends a message to the given recipient. |
||
54 | * |
||
55 | * @param RecipientInterface $recipient The recipient that should receive the message. |
||
56 | * @param Message $message The message that should be sent. |
||
57 | * @param string $subject The subject of the message. |
||
58 | * @param string $text The plain text message. |
||
59 | * @param null|string $html An optional HTML version of the message. |
||
60 | */ |
||
61 | abstract protected function sendToRecipient( |
||
68 | |||
69 | /** |
||
70 | * Gets the addresses for this transport. |
||
71 | * |
||
72 | * @param RecipientInterface $recipient |
||
73 | * @param Message $message |
||
74 | * @return array |
||
75 | */ |
||
76 | protected function getAddresses(RecipientInterface $recipient, Message $message): array |
||
82 | |||
83 | /** |
||
84 | * Gets the value of field "fromAddress". |
||
85 | * |
||
86 | * @return null|string |
||
87 | */ |
||
88 | public function getFromAddress(): ?string |
||
92 | |||
93 | /** |
||
94 | * Sets the value of field "fromAddress". |
||
95 | * |
||
96 | * @param null|string $fromAddress |
||
97 | */ |
||
98 | public function setFromAddress(?string $fromAddress) |
||
102 | |||
103 | /** |
||
104 | * Gets the value of field "fromName". |
||
105 | * |
||
106 | * @return null|string |
||
107 | */ |
||
108 | public function getFromName(): ?string |
||
112 | |||
113 | /** |
||
114 | * Sets the value of field "fromName". |
||
115 | * |
||
116 | * @param null|string $fromName |
||
117 | */ |
||
118 | public function setFromName(?string $fromName) |
||
122 | } |
||
123 |