1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Copyright (C) |
6
|
|
|
* Nathan Boiron <[email protected]> |
7
|
|
|
* Romain Canon <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This file is part of the TYPO3 NotiZ project. |
10
|
|
|
* It is free software; you can redistribute it and/or modify it |
11
|
|
|
* under the terms of the GNU General Public License, either |
12
|
|
|
* version 3 of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, see: |
15
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Notification\Activable; |
21
|
|
|
use CuyZ\Notiz\Core\Notification\Creatable; |
22
|
|
|
use CuyZ\Notiz\Core\Notification\Viewable; |
23
|
|
|
use CuyZ\Notiz\Core\Notification\Editable; |
24
|
|
|
use CuyZ\Notiz\Core\Notification\CustomSettingsNotification; |
25
|
|
|
use CuyZ\Notiz\Core\Property\PropertyEntry; |
26
|
|
|
use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Processor\EntityEmailNotificationProcessor; |
27
|
|
|
use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\EntityEmailSettings; |
28
|
|
|
use CuyZ\Notiz\Domain\Notification\Email\EmailNotification; |
29
|
|
|
use CuyZ\Notiz\Domain\Notification\EntityNotification; |
30
|
|
|
use CuyZ\Notiz\Domain\Property\Email; |
31
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
32
|
|
|
use TYPO3\CMS\Extbase\Service\FlexFormService; |
|
|
|
|
33
|
|
|
|
34
|
|
|
class EntityEmailNotification extends EntityNotification implements |
35
|
|
|
EmailNotification, |
36
|
|
|
CustomSettingsNotification, |
37
|
|
|
Creatable, |
38
|
|
|
Editable, |
39
|
|
|
Viewable, |
40
|
|
|
Activable |
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $layout; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $sender; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var bool |
54
|
|
|
*/ |
55
|
|
|
protected $senderCustom; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
protected $sendTo; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
protected $sendToProvided; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
protected $sendCc; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var string |
74
|
|
|
*/ |
75
|
|
|
protected $sendCcProvided; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var string |
79
|
|
|
*/ |
80
|
|
|
protected $sendBcc; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var string |
84
|
|
|
*/ |
85
|
|
|
protected $sendBccProvided; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var string |
89
|
|
|
*/ |
90
|
|
|
protected $subject; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var string |
94
|
|
|
*/ |
95
|
|
|
protected $body; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var array |
99
|
|
|
*/ |
100
|
|
|
protected $bodySlots = []; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getLayout(): string |
106
|
|
|
{ |
107
|
|
|
return $this->layout; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $layout |
112
|
|
|
*/ |
113
|
|
|
public function setLayout(string $layout) |
114
|
|
|
{ |
115
|
|
|
$this->layout = $layout; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return string |
120
|
|
|
*/ |
121
|
|
|
public function getSender(): string |
122
|
|
|
{ |
123
|
|
|
return $this->sender; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param string $sender |
128
|
|
|
*/ |
129
|
|
|
public function setSender(string $sender) |
130
|
|
|
{ |
131
|
|
|
$this->sender = $sender; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return bool |
136
|
|
|
*/ |
137
|
|
|
public function isSenderCustom(): bool |
138
|
|
|
{ |
139
|
|
|
return $this->senderCustom; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param bool $senderCustom |
144
|
|
|
*/ |
145
|
|
|
public function setSenderCustom(bool $senderCustom) |
146
|
|
|
{ |
147
|
|
|
$this->senderCustom = $senderCustom; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getSendTo(): string |
154
|
|
|
{ |
155
|
|
|
return $this->sendTo; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param string $sendTo |
160
|
|
|
*/ |
161
|
|
|
public function setSendTo(string $sendTo) |
162
|
|
|
{ |
163
|
|
|
$this->sendTo = $sendTo; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return string |
168
|
|
|
*/ |
169
|
|
|
public function getSendToProvided(): string |
170
|
|
|
{ |
171
|
|
|
return $this->sendToProvided; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return Email[] |
176
|
|
|
*/ |
177
|
|
|
public function getSelectedSendToProvided(): array |
178
|
|
|
{ |
179
|
|
|
return $this->getSelectedProvidedRecipients($this->sendToProvided); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param string $sendToProvided |
184
|
|
|
*/ |
185
|
|
|
public function setSendToProvided(string $sendToProvided) |
186
|
|
|
{ |
187
|
|
|
$this->sendToProvided = $sendToProvided; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return string |
192
|
|
|
*/ |
193
|
|
|
public function getSendCc(): string |
194
|
|
|
{ |
195
|
|
|
return $this->sendCc; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param string $sendCc |
200
|
|
|
*/ |
201
|
|
|
public function setSendCc(string $sendCc) |
202
|
|
|
{ |
203
|
|
|
$this->sendCc = $sendCc; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return string |
208
|
|
|
*/ |
209
|
|
|
public function getSendCcProvided(): string |
210
|
|
|
{ |
211
|
|
|
return $this->sendCcProvided; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return Email[] |
216
|
|
|
*/ |
217
|
|
|
public function getSelectedSendCcProvided(): array |
218
|
|
|
{ |
219
|
|
|
return $this->getSelectedProvidedRecipients($this->sendCcProvided); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @param string $sendCcProvided |
224
|
|
|
*/ |
225
|
|
|
public function setSendCcProvided(string $sendCcProvided) |
226
|
|
|
{ |
227
|
|
|
$this->sendCcProvided = $sendCcProvided; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return string |
232
|
|
|
*/ |
233
|
|
|
public function getSendBcc(): string |
234
|
|
|
{ |
235
|
|
|
return $this->sendBcc; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @param string $sendBcc |
240
|
|
|
*/ |
241
|
|
|
public function setSendBcc(string $sendBcc) |
242
|
|
|
{ |
243
|
|
|
$this->sendBcc = $sendBcc; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @return string |
248
|
|
|
*/ |
249
|
|
|
public function getSendBccProvided(): string |
250
|
|
|
{ |
251
|
|
|
return $this->sendBccProvided; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @return Email[] |
256
|
|
|
*/ |
257
|
|
|
public function getSelectedSendBccProvided(): array |
258
|
|
|
{ |
259
|
|
|
return $this->getSelectedProvidedRecipients($this->sendBccProvided); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @param string $sendBccProvided |
264
|
|
|
*/ |
265
|
|
|
public function setSendBccProvided(string $sendBccProvided) |
266
|
|
|
{ |
267
|
|
|
$this->sendBccProvided = $sendBccProvided; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @return string |
272
|
|
|
*/ |
273
|
|
|
public function getSubject(): string |
274
|
|
|
{ |
275
|
|
|
return $this->subject; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @param string $subject |
280
|
|
|
*/ |
281
|
|
|
public function setSubject(string $subject) |
282
|
|
|
{ |
283
|
|
|
$this->subject = $subject; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @return string |
288
|
|
|
*/ |
289
|
|
|
public function getBody(): string |
290
|
|
|
{ |
291
|
|
|
return $this->body; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @return array |
296
|
|
|
*/ |
297
|
|
|
public function getBodySlots(): array |
298
|
|
|
{ |
299
|
|
|
if (empty($this->bodySlots)) { |
300
|
|
|
/** @var FlexFormService $flexFormService */ |
301
|
|
|
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class); |
302
|
|
|
|
303
|
|
|
$this->bodySlots = $flexFormService->convertFlexFormContentToArray($this->body); |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
return $this->bodySlots; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @param string $body |
311
|
|
|
*/ |
312
|
|
|
public function setBody(string $body) |
313
|
|
|
{ |
314
|
|
|
$this->body = $body; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @return string |
319
|
|
|
*/ |
320
|
|
|
public static function getProcessorClassName(): string |
321
|
|
|
{ |
322
|
|
|
return EntityEmailNotificationProcessor::class; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @return string |
327
|
|
|
*/ |
328
|
|
|
public static function getDefinitionIdentifier(): string |
329
|
|
|
{ |
330
|
|
|
return 'entityEmail'; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* @return string |
335
|
|
|
*/ |
336
|
|
|
public static function getSettingsClassName(): string |
337
|
|
|
{ |
338
|
|
|
return EntityEmailSettings::class; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* @param string $providedRecipients |
343
|
|
|
* @return Email[] |
344
|
|
|
*/ |
345
|
|
|
protected function getSelectedProvidedRecipients(string $providedRecipients): array |
346
|
|
|
{ |
347
|
|
|
if (!$this->hasEventDefinition()) { |
348
|
|
|
return []; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
$providedRecipients = GeneralUtility::trimExplode(',', $providedRecipients); |
352
|
|
|
|
353
|
|
|
return array_filter( |
354
|
|
|
$this->getEmailProperties(), |
355
|
|
|
function (Email $email) use ($providedRecipients) { |
356
|
|
|
return in_array($email->getName(), $providedRecipients); |
357
|
|
|
} |
358
|
|
|
); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @return PropertyEntry[]|Email[] |
363
|
|
|
*/ |
364
|
|
|
protected function getEmailProperties() |
365
|
|
|
{ |
366
|
|
|
return $this->getEventDefinition() |
367
|
|
|
->getPropertyDefinition(Email::class, $this) |
368
|
|
|
->getEntries(); |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths