1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Communicator (https://github.com/waltertamboer/communicator) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/waltertamboer/communicator for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2017 Communicator (https://github.com/waltertamboer/communicator) |
7
|
|
|
* @license https://github.com/waltertamboer/communicator/blob/master/LICENSE.md MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Communicator\Transport\Email\Transport; |
11
|
|
|
|
12
|
|
|
use Communicator\Message; |
13
|
|
|
use Communicator\Recipient\RecipientInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* A base class for email transports. |
17
|
|
|
*/ |
18
|
|
|
abstract class AbstractTransport implements TransportInterface |
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
|
|
|
* Gets the addresses for this transport. |
36
|
|
|
* |
37
|
|
|
* @param RecipientInterface $recipient |
38
|
|
|
* @param Message $message |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
|
|
protected function getAddresses(RecipientInterface $recipient, Message $message): array |
42
|
|
|
{ |
43
|
|
|
$parameters = (array)$message->getOption('recipient_parameters', []); |
44
|
|
|
|
45
|
|
|
return $recipient->getNotificationRecipientAddresses('email', $parameters); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Gets the value of field "fromAddress". |
50
|
|
|
* |
51
|
|
|
* @return null|string |
52
|
|
|
*/ |
53
|
|
|
public function getFromAddress(): ?string |
54
|
|
|
{ |
55
|
|
|
return $this->fromAddress; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Sets the value of field "fromAddress". |
60
|
|
|
* |
61
|
|
|
* @param null|string $fromAddress |
62
|
|
|
*/ |
63
|
|
|
public function setFromAddress(?string $fromAddress) |
64
|
|
|
{ |
65
|
|
|
$this->fromAddress = $fromAddress; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Gets the value of field "fromName". |
70
|
|
|
* |
71
|
|
|
* @return null|string |
72
|
|
|
*/ |
73
|
|
|
public function getFromName(): ?string |
74
|
|
|
{ |
75
|
|
|
return $this->fromName; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Sets the value of field "fromName". |
80
|
|
|
* |
81
|
|
|
* @param null|string $fromName |
82
|
|
|
*/ |
83
|
|
|
public function setFromName(?string $fromName) |
84
|
|
|
{ |
85
|
|
|
$this->fromName = $fromName; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|