|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright (C) 2020-2025 Iain Cambridge |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by |
|
10
|
|
|
* the Free Software Foundation, either version 2.1 of the License, or |
|
11
|
|
|
* (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Lesser General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU General Public License |
|
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace Parthenon\Notification; |
|
23
|
|
|
|
|
24
|
|
|
abstract class TemplateEmail implements EmailInterface |
|
25
|
|
|
{ |
|
26
|
|
|
private ?string $subject = null; |
|
27
|
|
|
|
|
28
|
|
|
private ?string $fromAddress = null; |
|
29
|
|
|
|
|
30
|
|
|
private ?string $fromName = null; |
|
31
|
|
|
|
|
32
|
|
|
private ?string $toAddress = null; |
|
33
|
|
|
|
|
34
|
|
|
private ?string $toName = null; |
|
35
|
|
|
|
|
36
|
|
|
private ?string $content = null; |
|
37
|
|
|
|
|
38
|
|
|
private array $templateVariables = []; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var Attachment[] |
|
42
|
|
|
*/ |
|
43
|
|
|
private array $attachments = []; |
|
44
|
|
|
|
|
45
|
|
|
public function getSubject(): ?string |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->subject; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function setSubject(?string $subject): self |
|
51
|
|
|
{ |
|
52
|
|
|
$this->subject = $subject; |
|
53
|
|
|
|
|
54
|
|
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getFromAddress(): ?string |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->fromAddress; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function setFromAddress(?string $fromAddress): self |
|
63
|
|
|
{ |
|
64
|
|
|
$this->fromAddress = $fromAddress; |
|
65
|
|
|
|
|
66
|
|
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function getFromName(): ?string |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->fromName; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function setFromName(?string $fromName): self |
|
75
|
|
|
{ |
|
76
|
|
|
$this->fromName = $fromName; |
|
77
|
|
|
|
|
78
|
|
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getToAddress(): ?string |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->toAddress; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function setToAddress(?string $toAddress): self |
|
87
|
|
|
{ |
|
88
|
|
|
$this->toAddress = $toAddress; |
|
89
|
|
|
|
|
90
|
|
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function getToName(): ?string |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->toName; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function setToName(?string $toName): self |
|
99
|
|
|
{ |
|
100
|
|
|
$this->toName = $toName; |
|
101
|
|
|
|
|
102
|
|
|
return $this; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function getContent(): ?string |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->content; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function setContent(?string $content): self |
|
111
|
|
|
{ |
|
112
|
|
|
$this->content = $content; |
|
113
|
|
|
|
|
114
|
|
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
abstract public function getTemplateName(): string; |
|
118
|
|
|
|
|
119
|
|
|
public function setTemplateVariables(array $templateVariables): self |
|
120
|
|
|
{ |
|
121
|
|
|
$this->templateVariables = $templateVariables; |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getTemplateVariables(): array |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->templateVariables; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function isTemplate(): bool |
|
132
|
|
|
{ |
|
133
|
|
|
return true; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function addAttachment(Attachment $attachment): self |
|
137
|
|
|
{ |
|
138
|
|
|
$this->attachments[] = $attachment; |
|
139
|
|
|
|
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @return Attachment[] |
|
145
|
|
|
*/ |
|
146
|
|
|
public function getAttachments(): array |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->attachments; |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|