1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please read the |
7
|
|
|
* LICENSE.txt file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace DERHANSEN\SfEventMgt\Service; |
11
|
|
|
|
12
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; |
13
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Event; |
14
|
|
|
use DERHANSEN\SfEventMgt\Event\AfterAdminMessageSentEvent; |
15
|
|
|
use DERHANSEN\SfEventMgt\Event\AfterUserMessageSentEvent; |
16
|
|
|
use DERHANSEN\SfEventMgt\Event\ModifyUserMessageAttachmentsEvent; |
17
|
|
|
use DERHANSEN\SfEventMgt\Event\ModifyUserMessageSenderEvent; |
18
|
|
|
use DERHANSEN\SfEventMgt\Utility\MessageRecipient; |
19
|
|
|
use DERHANSEN\SfEventMgt\Utility\MessageType; |
20
|
|
|
use Psr\EventDispatcher\EventDispatcherInterface; |
21
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* NotificationService |
25
|
|
|
* |
26
|
|
|
* @author Torben Hansen <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class NotificationService |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* The object manager |
32
|
|
|
* |
33
|
|
|
* @var \TYPO3\CMS\Extbase\Object\ObjectManager |
34
|
|
|
*/ |
35
|
|
|
protected $objectManager; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Registration repository |
39
|
|
|
* |
40
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository |
41
|
|
|
*/ |
42
|
|
|
protected $registrationRepository; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Email Service |
46
|
|
|
* |
47
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\EmailService |
48
|
|
|
*/ |
49
|
|
|
protected $emailService; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Hash Service |
53
|
|
|
* |
54
|
|
|
* @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService |
55
|
|
|
*/ |
56
|
|
|
protected $hashService; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* FluidStandaloneService |
60
|
|
|
* |
61
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\FluidStandaloneService |
62
|
|
|
*/ |
63
|
|
|
protected $fluidStandaloneService; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* CustomNotificationLogRepository |
67
|
|
|
* |
68
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
69
|
|
|
*/ |
70
|
|
|
protected $customNotificationLogRepository; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* AttachmentService |
74
|
|
|
* |
75
|
|
|
* @var \DERHANSEN\SfEventMgt\Service\Notification\AttachmentService |
76
|
|
|
*/ |
77
|
|
|
protected $attachmentService; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var EventDispatcherInterface |
81
|
|
|
*/ |
82
|
|
|
protected $eventDispatcher; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* DI for $attachmentService |
86
|
|
|
* |
87
|
|
|
* @param Notification\AttachmentService $attachmentService |
88
|
|
|
*/ |
89
|
|
|
public function injectAttachmentService( |
90
|
|
|
\DERHANSEN\SfEventMgt\Service\Notification\AttachmentService $attachmentService |
91
|
|
|
) { |
92
|
|
|
$this->attachmentService = $attachmentService; |
93
|
|
|
} |
94
|
|
|
|
95
|
8 |
|
/** |
96
|
|
|
* DI for $customNotificationLogRepository |
97
|
8 |
|
* |
98
|
2 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
99
|
|
|
*/ |
100
|
6 |
|
public function injectCustomNotificationLogRepository( |
101
|
|
|
\DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
102
|
6 |
|
) { |
103
|
6 |
|
$this->customNotificationLogRepository = $customNotificationLogRepository; |
104
|
6 |
|
} |
105
|
|
|
|
106
|
6 |
|
/** |
107
|
2 |
|
* DI for $emailService |
108
|
2 |
|
* |
109
|
2 |
|
* @param EmailService $emailService |
110
|
2 |
|
*/ |
111
|
2 |
|
public function injectEmailService(\DERHANSEN\SfEventMgt\Service\EmailService $emailService) |
112
|
|
|
{ |
113
|
2 |
|
$this->emailService = $emailService; |
114
|
2 |
|
} |
115
|
2 |
|
|
116
|
2 |
|
/** |
117
|
2 |
|
* DI for $fluidStandaloneService |
118
|
6 |
|
* |
119
|
6 |
|
* @param FluidStandaloneService $fluidStandaloneService |
120
|
|
|
*/ |
121
|
|
|
public function injectFluidStandaloneService( |
122
|
|
|
\DERHANSEN\SfEventMgt\Service\FluidStandaloneService $fluidStandaloneService |
123
|
|
|
) { |
124
|
|
|
$this->fluidStandaloneService = $fluidStandaloneService; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* DI for $hashService |
129
|
|
|
* |
130
|
|
|
* @param \TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService |
131
|
8 |
|
*/ |
132
|
|
|
public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService) |
133
|
8 |
|
{ |
134
|
|
|
$this->hashService = $hashService; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* DI for $objectManager |
139
|
|
|
* |
140
|
|
|
* @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager |
141
|
|
|
*/ |
142
|
|
|
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager) |
143
|
|
|
{ |
144
|
|
|
$this->objectManager = $objectManager; |
145
|
2 |
|
} |
146
|
|
|
|
147
|
2 |
|
/** |
148
|
2 |
|
* DI for $registrationRepository |
149
|
2 |
|
* |
150
|
2 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository |
151
|
2 |
|
*/ |
152
|
2 |
|
public function injectRegistrationRepository( |
153
|
2 |
|
\DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository |
154
|
|
|
) { |
155
|
|
|
$this->registrationRepository = $registrationRepository; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param EventDispatcherInterface $eventDispatcher |
160
|
|
|
*/ |
161
|
|
|
public function injectEventDispatcher(EventDispatcherInterface $eventDispatcher) |
162
|
|
|
{ |
163
|
|
|
$this->eventDispatcher = $eventDispatcher; |
164
|
|
|
} |
165
|
|
|
|
166
|
34 |
|
/** |
167
|
|
|
* Sends a custom notification defined by the given customNotification key |
168
|
34 |
|
* to all confirmed users of the event |
169
|
|
|
* |
170
|
34 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event |
171
|
4 |
|
* @param CustomNotification $customNotification |
172
|
|
|
* @param array $settings Settings |
173
|
|
|
* |
174
|
30 |
|
* @return int Number of notifications sent |
175
|
20 |
|
*/ |
176
|
20 |
|
public function sendCustomNotification(Event $event, CustomNotification $customNotification, array $settings = []) |
177
|
20 |
|
{ |
178
|
20 |
|
if ($this->cantSendCustomNotification($event, $settings, $customNotification)) { |
179
|
20 |
|
return 0; |
180
|
|
|
} |
181
|
20 |
|
$count = 0; |
182
|
20 |
|
|
183
|
20 |
|
$customNotificationSettings = $settings['notification']['customNotifications']; |
184
|
20 |
|
$constraints = $customNotificationSettings[$customNotification->getTemplate()]['constraints'] ?? []; |
185
|
20 |
|
$registrations = $this->registrationRepository->findNotificationRegistrations( |
186
|
20 |
|
$event, |
187
|
20 |
|
$customNotification, |
188
|
|
|
$constraints |
189
|
20 |
|
); |
190
|
|
|
|
191
|
10 |
|
foreach ($registrations as $registration) { |
192
|
|
|
/** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration */ |
193
|
|
|
$result = $this->sendUserMessage( |
194
|
|
|
$event, |
195
|
|
|
$registration, |
196
|
|
|
$settings, |
197
|
|
|
MessageType::CUSTOM_NOTIFICATION, |
198
|
|
|
$customNotification |
199
|
|
|
); |
200
|
|
|
if ($result) { |
201
|
|
|
$count += 1; |
202
|
34 |
|
} |
203
|
|
|
} |
204
|
34 |
|
|
205
|
34 |
|
return $count; |
206
|
|
|
} |
207
|
34 |
|
|
208
|
6 |
|
/** |
209
|
6 |
|
* Returns true if conditions are not met to send a custom notification |
210
|
6 |
|
* |
211
|
28 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event |
212
|
6 |
|
* @param array $settings |
213
|
6 |
|
* @param CustomNotification $customNotification |
214
|
6 |
|
* |
215
|
22 |
|
* @return bool |
216
|
6 |
|
*/ |
217
|
6 |
|
protected function cantSendCustomNotification($event, $settings, $customNotification) |
218
|
6 |
|
{ |
219
|
16 |
|
return is_null($event) || $customNotification === null || $customNotification->getTemplate() === '' || |
220
|
|
|
empty($settings); |
221
|
|
|
} |
222
|
|
|
|
223
|
16 |
|
/** |
224
|
2 |
|
* Adds a logentry to the custom notification log |
225
|
2 |
|
* |
226
|
2 |
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
227
|
14 |
|
* @param string $details Details |
228
|
14 |
|
* @param int $emailsSent E-Mails sent |
229
|
14 |
|
*/ |
230
|
|
|
public function createCustomNotificationLogentry($event, $details, $emailsSent) |
231
|
34 |
|
{ |
232
|
|
|
$notificationlogEntry = new \DERHANSEN\SfEventMgt\Domain\Model\CustomNotificationLog(); |
233
|
34 |
|
$notificationlogEntry->setPid($event->getPid()); |
234
|
|
|
$notificationlogEntry->setEvent($event); |
235
|
|
|
$notificationlogEntry->setDetails($details); |
236
|
|
|
$notificationlogEntry->setEmailsSent($emailsSent); |
237
|
|
|
$notificationlogEntry->setCruserId($GLOBALS['BE_USER']->user['uid']); |
238
|
|
|
$this->customNotificationLogRepository->add($notificationlogEntry); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Sends a message to the user based on the given type |
243
|
|
|
* |
244
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
245
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
246
|
52 |
|
* @param array $settings Settings |
247
|
|
|
* @param int $type Type |
248
|
52 |
|
* @param CustomNotification $customNotification |
249
|
|
|
* |
250
|
|
|
* @return bool TRUE if successful, else FALSE |
251
|
52 |
|
*/ |
252
|
50 |
|
public function sendUserMessage($event, $registration, $settings, $type, $customNotification = null) |
253
|
52 |
|
{ |
254
|
12 |
|
list($template, $subject) = $this->getUserMessageTemplateSubject( |
255
|
|
|
$settings, |
256
|
|
|
$type, |
257
|
40 |
|
$customNotification |
258
|
40 |
|
); |
259
|
40 |
|
|
260
|
40 |
|
if (is_null($event) || is_null($registration) || is_null($type) || !is_array($settings) || |
261
|
40 |
|
(substr($template, -5) != '.html') || (bool)$settings['notification']['disabled'] |
262
|
40 |
|
) { |
263
|
|
|
return false; |
264
|
40 |
|
} |
265
|
40 |
|
|
266
|
30 |
|
$additionalBodyVariables = [ |
267
|
30 |
|
'customNotification' => $customNotification |
268
|
30 |
|
]; |
269
|
30 |
|
|
270
|
30 |
|
if (!$registration->isIgnoreNotifications()) { |
271
|
30 |
|
$body = $this->getNotificationBody($event, $registration, $template, $settings, $additionalBodyVariables); |
272
|
30 |
|
$subject = $this->fluidStandaloneService->parseStringFluid( |
273
|
30 |
|
$subject, |
274
|
|
|
[ |
275
|
30 |
|
'event' => $event, |
276
|
30 |
|
'registration' => $registration |
277
|
30 |
|
] |
278
|
40 |
|
); |
279
|
10 |
|
$attachments = $this->attachmentService->getAttachments( |
280
|
10 |
|
$settings, |
281
|
10 |
|
$registration, |
282
|
10 |
|
$type, |
283
|
10 |
|
MessageRecipient::USER |
284
|
10 |
|
); |
285
|
|
|
|
286
|
10 |
|
// Get iCal attachment if configured |
287
|
10 |
|
$iCalAttachment = $this->attachmentService->getICalAttachment( |
288
|
40 |
|
$settings, |
289
|
|
|
$registration, |
290
|
|
|
$type, |
291
|
|
|
MessageRecipient::USER |
292
|
|
|
); |
293
|
|
|
|
294
|
|
|
if ($iCalAttachment !== '') { |
295
|
|
|
$attachments[] = $iCalAttachment; |
296
|
|
|
} |
297
|
|
|
|
298
|
52 |
|
$modifyUserMessageSenderEvent = new ModifyUserMessageSenderEvent( |
299
|
|
|
$settings['notification']['senderName'] ?? '', |
300
|
52 |
|
$settings['notification']['senderEmail'] ?? '', |
301
|
52 |
|
$settings['notification']['replyToEmail'] ?? '', |
302
|
|
|
$registration, |
303
|
52 |
|
$type, |
304
|
10 |
|
$this |
305
|
10 |
|
); |
306
|
10 |
|
$this->eventDispatcher->dispatch($modifyUserMessageSenderEvent); |
|
|
|
|
307
|
42 |
|
$senderName = $modifyUserMessageSenderEvent->getSenderName(); |
308
|
10 |
|
$senderEmail = $modifyUserMessageSenderEvent->getSenderEmail(); |
309
|
10 |
|
$replyToEmail = $modifyUserMessageSenderEvent->getReplyToEmail(); |
310
|
10 |
|
|
311
|
32 |
|
$modifyUserAttachmentsEvent = new ModifyUserMessageAttachmentsEvent( |
312
|
10 |
|
$attachments, |
313
|
10 |
|
$registration, |
314
|
10 |
|
$type, |
315
|
22 |
|
$this |
316
|
|
|
); |
317
|
|
|
$this->eventDispatcher->dispatch($modifyUserMessageSenderEvent); |
|
|
|
|
318
|
|
|
$attachments = $modifyUserAttachmentsEvent->getAttachments(); |
319
|
22 |
|
|
320
|
22 |
|
$result = $this->emailService->sendEmailMessage( |
321
|
22 |
|
$senderEmail, |
322
|
|
|
$registration->getEmail(), |
323
|
52 |
|
$subject, |
324
|
|
|
$body, |
325
|
52 |
|
$senderName, |
326
|
|
|
$attachments, |
327
|
|
|
$replyToEmail |
328
|
|
|
); |
329
|
|
|
|
330
|
|
|
$afterUserMessageSentEvent = new AfterUserMessageSentEvent( |
331
|
|
|
$registration, |
332
|
|
|
$body, |
333
|
|
|
$subject, |
334
|
|
|
$attachments, |
335
|
|
|
$senderName, |
336
|
|
|
$senderEmail, |
337
|
|
|
$replyToEmail, |
338
|
60 |
|
$this |
339
|
|
|
); |
340
|
|
|
$this->eventDispatcher->dispatch($afterUserMessageSentEvent); |
|
|
|
|
341
|
60 |
|
|
342
|
60 |
|
// Cleanup iCal attachment if available |
343
|
60 |
|
if ($iCalAttachment !== '') { |
344
|
60 |
|
\TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($iCalAttachment); |
345
|
|
|
} |
346
|
60 |
|
|
347
|
|
|
return $result; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
return false; |
351
|
|
|
} |
352
|
60 |
|
|
353
|
60 |
|
/** |
354
|
60 |
|
* Returns an array with template and subject for the user message |
355
|
60 |
|
* |
356
|
60 |
|
* @param array $settings |
357
|
60 |
|
* @param int $type Type |
358
|
60 |
|
* @param CustomNotification $customNotification |
359
|
60 |
|
* @return array |
360
|
60 |
|
*/ |
361
|
60 |
|
protected function getUserMessageTemplateSubject($settings, $type, $customNotification = null) |
362
|
60 |
|
{ |
363
|
60 |
|
switch ($type) { |
364
|
|
|
case MessageType::REGISTRATION_NEW: |
365
|
|
|
$template = 'Notification/User/RegistrationNew.html'; |
366
|
|
|
$subject = $settings['notification']['registrationNew']['userSubject']; |
367
|
|
|
break; |
368
|
|
|
case MessageType::REGISTRATION_WAITLIST_NEW: |
369
|
|
|
$template = 'Notification/User/RegistrationWaitlistNew.html'; |
370
|
|
|
$subject = $settings['notification']['registrationWaitlistNew']['userSubject']; |
371
|
|
|
break; |
372
|
|
|
case MessageType::REGISTRATION_CONFIRMED: |
373
|
|
|
$template = 'Notification/User/RegistrationConfirmed.html'; |
374
|
|
|
$subject = $settings['notification']['registrationConfirmed']['userSubject']; |
375
|
|
|
break; |
376
|
|
|
case MessageType::REGISTRATION_WAITLIST_CONFIRMED: |
377
|
|
|
$template = 'Notification/User/RegistrationWaitlistConfirmed.html'; |
378
|
|
|
$subject = $settings['notification']['registrationWaitlistConfirmed']['userSubject']; |
379
|
|
|
break; |
380
|
|
|
case MessageType::REGISTRATION_CANCELLED: |
381
|
|
|
$template = 'Notification/User/RegistrationCancelled.html'; |
382
|
|
|
$subject = $settings['notification']['registrationCancelled']['userSubject']; |
383
|
|
|
break; |
384
|
|
|
case MessageType::CUSTOM_NOTIFICATION && $customNotification: |
385
|
|
|
$customNotificationSettings = $settings['notification']['customNotifications']; |
386
|
|
|
$templateKey = $customNotification->getTemplate(); |
|
|
|
|
387
|
|
|
$template = 'Notification/User/Custom/' . $customNotificationSettings[$templateKey]['template']; |
388
|
|
|
$subject = $customNotificationSettings[$templateKey]['subject']; |
389
|
|
|
if ($customNotification->getOverwriteSubject() !== '') { |
390
|
|
|
$subject = $customNotification->getOverwriteSubject(); |
391
|
|
|
} |
392
|
|
|
break; |
393
|
|
|
default: |
394
|
|
|
$template = ''; |
395
|
|
|
$subject = ''; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
return [ |
399
|
|
|
$template, |
400
|
|
|
$subject |
401
|
|
|
]; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Sends a message to the admin based on the given type |
406
|
|
|
* |
407
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
408
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
409
|
|
|
* @param array $settings Settings |
410
|
|
|
* @param int $type Type |
411
|
|
|
* |
412
|
|
|
* @return bool TRUE if successful, else FALSE |
413
|
|
|
*/ |
414
|
|
|
public function sendAdminMessage($event, $registration, $settings, $type) |
415
|
|
|
{ |
416
|
|
|
list($template, $subject) = $this->getAdminMessageTemplateSubject($settings, $type); |
417
|
|
|
|
418
|
|
|
if (is_null($event) || is_null($registration || !is_array($settings)) || |
419
|
|
|
($event->getNotifyAdmin() === false && $event->getNotifyOrganisator() === false) || |
420
|
|
|
(bool)$settings['notification']['disabled'] |
421
|
|
|
) { |
422
|
|
|
return false; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
$allEmailsSent = true; |
426
|
|
|
$body = $this->getNotificationBody($event, $registration, $template, $settings); |
427
|
|
|
$subject = $this->fluidStandaloneService->parseStringFluid( |
428
|
|
|
$subject, |
429
|
|
|
[ |
430
|
|
|
'event' => $event, |
431
|
|
|
'registration' => $registration |
432
|
|
|
] |
433
|
|
|
); |
434
|
|
|
$attachments = $this->attachmentService->getAttachments( |
435
|
|
|
$settings, |
436
|
|
|
$registration, |
437
|
|
|
$type, |
438
|
|
|
MessageRecipient::ADMIN |
439
|
|
|
); |
440
|
|
|
|
441
|
|
|
$senderName = $settings['notification']['senderName']; |
442
|
|
|
$senderEmail = $settings['notification']['senderEmail']; |
443
|
|
|
if ((bool)$settings['notification']['registrationDataAsSenderForAdminEmails']) { |
444
|
|
|
$senderName = $registration->getFullname(); |
445
|
|
|
$senderEmail = $registration->getEmail(); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
if ($event->getNotifyAdmin()) { |
449
|
|
|
$adminEmailArr = GeneralUtility::trimExplode(',', $settings['notification']['adminEmail'], true); |
450
|
|
|
foreach ($adminEmailArr as $adminEmail) { |
451
|
|
|
$allEmailsSent = $allEmailsSent && $this->emailService->sendEmailMessage( |
452
|
|
|
$senderEmail, |
453
|
|
|
$adminEmail, |
454
|
|
|
$subject, |
455
|
|
|
$body, |
456
|
|
|
$senderName, |
457
|
|
|
$attachments |
458
|
|
|
); |
459
|
|
|
} |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
if ($event->getNotifyOrganisator() && $event->getOrganisator()) { |
463
|
|
|
$allEmailsSent = $allEmailsSent && $this->emailService->sendEmailMessage( |
464
|
|
|
$senderEmail, |
465
|
|
|
$event->getOrganisator()->getEmail(), |
466
|
|
|
$subject, |
467
|
|
|
$body, |
468
|
|
|
$senderName, |
469
|
|
|
$attachments |
470
|
|
|
); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
$afterAdminMessageSentEvent = new AfterAdminMessageSentEvent( |
474
|
|
|
$registration, |
475
|
|
|
$body, |
476
|
|
|
$subject, |
477
|
|
|
$attachments, |
478
|
|
|
$senderName, |
479
|
|
|
$senderEmail, |
480
|
|
|
$this |
481
|
|
|
); |
482
|
|
|
$this->eventDispatcher->dispatch($afterAdminMessageSentEvent); |
|
|
|
|
483
|
|
|
|
484
|
|
|
return $allEmailsSent; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Returns an array with template and subject for the admin message |
489
|
|
|
* |
490
|
|
|
* @param array $settings |
491
|
|
|
* @param int $type Type |
492
|
|
|
* @return array |
493
|
|
|
*/ |
494
|
|
|
protected function getAdminMessageTemplateSubject($settings, $type) |
495
|
|
|
{ |
496
|
|
|
$template = 'Notification/Admin/RegistrationNew.html'; |
497
|
|
|
$subject = $settings['notification']['registrationNew']['adminSubject']; |
498
|
|
|
switch ($type) { |
499
|
|
|
case MessageType::REGISTRATION_WAITLIST_NEW: |
500
|
|
|
$template = 'Notification/Admin/RegistrationWaitlistNew.html'; |
501
|
|
|
$subject = $settings['notification']['registrationWaitlistNew']['adminSubject']; |
502
|
|
|
break; |
503
|
|
|
case MessageType::REGISTRATION_CONFIRMED: |
504
|
|
|
$template = 'Notification/Admin/RegistrationConfirmed.html'; |
505
|
|
|
$subject = $settings['notification']['registrationConfirmed']['adminSubject']; |
506
|
|
|
break; |
507
|
|
|
case MessageType::REGISTRATION_WAITLIST_CONFIRMED: |
508
|
|
|
$template = 'Notification/Admin/RegistrationWaitlistConfirmed.html'; |
509
|
|
|
$subject = $settings['notification']['registrationWaitlistConfirmed']['adminSubject']; |
510
|
|
|
break; |
511
|
|
|
case MessageType::REGISTRATION_CANCELLED: |
512
|
|
|
$template = 'Notification/Admin/RegistrationCancelled.html'; |
513
|
|
|
$subject = $settings['notification']['registrationCancelled']['adminSubject']; |
514
|
|
|
break; |
515
|
|
|
case MessageType::REGISTRATION_NEW: |
516
|
|
|
default: |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
return [ |
520
|
|
|
$template, |
521
|
|
|
$subject |
522
|
|
|
]; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* Returns the rendered HTML for the given template |
527
|
|
|
* |
528
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
529
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
530
|
|
|
* @param string $template Template |
531
|
|
|
* @param array $settings Settings |
532
|
|
|
* @param array $additionalBodyVariables |
533
|
|
|
* @return string |
534
|
|
|
*/ |
535
|
|
|
protected function getNotificationBody($event, $registration, $template, $settings, $additionalBodyVariables = []) |
536
|
|
|
{ |
537
|
|
|
if (TYPO3_MODE === 'BE' && $registration->getLanguage() !== '') { |
538
|
|
|
// Temporary set Language of current BE user to given language |
539
|
|
|
$GLOBALS['BE_USER']->uc['lang'] = $registration->getLanguage(); |
540
|
|
|
} |
541
|
|
|
$defaultVariables = [ |
542
|
|
|
'event' => $event, |
543
|
|
|
'registration' => $registration, |
544
|
|
|
'settings' => $settings, |
545
|
|
|
'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid()), |
546
|
|
|
'reghmac' => $this->hashService->appendHmac((string)$registration->getUid()) |
547
|
|
|
]; |
548
|
|
|
$variables = array_merge($additionalBodyVariables, $defaultVariables); |
549
|
|
|
|
550
|
|
|
return $this->fluidStandaloneService->renderTemplate($template, $variables); |
551
|
|
|
} |
552
|
|
|
} |
553
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: