Skip to content

Commit dacbb0f

Browse files
committed
5472: Use sender label in Maestro digital post notification
1 parent 16e7e29 commit dacbb0f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

modules/os2forms_forloeb/src/MaestroHelper.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,14 @@ private function sendNotification(
250250
'subject' => $subject,
251251
'taskUrl' => $taskUrl,
252252
'actionLabel' => $actionLabel,
253+
'senderLabel' => $senderLabel,
253254
] = $this->renderNotification($submission, $handler->getHandlerId(), $notificationType, $templateTask, $maestroQueueID);
254255

255256
if ('email' === $contentType) {
256257
$this->sendNotificationEmail($recipient, $subject, $content, $submission, $notificationType);
257258
}
258259
else {
259-
$this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType);
260+
$this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType, $senderLabel);
260261
}
261262
}
262263
}
@@ -368,7 +369,9 @@ private function sendNotificationEmail(
368369
* @param \Drupal\webform\WebformSubmissionInterface $submission
369370
* The webform submission.
370371
* @param string $notificationType
371-
* The notification type (one of the NOTIFICATION_* constannts).
372+
* The notification type (one of the NOTIFICATION_* constants).
373+
* @param string $senderLabel
374+
* The sender label.
372375
*/
373376
private function sendNotificationDigitalPost(
374377
string $recipient,
@@ -378,6 +381,7 @@ private function sendNotificationDigitalPost(
378381
string $actionLabel,
379382
WebformSubmissionInterface $submission,
380383
string $notificationType,
384+
string $senderLabel,
381385
): void {
382386
try {
383387
$document = new Document(
@@ -386,7 +390,6 @@ private function sendNotificationDigitalPost(
386390
$subject . '.pdf'
387391
);
388392

389-
$senderLabel = $subject;
390393
$messageLabel = $subject;
391394

392395
$recipientLookupResult = $this->digitalPostHelper->lookupRecipient($recipient);
@@ -436,13 +439,13 @@ private function sendNotificationDigitalPost(
436439
* @param string $handlerId
437440
* The handler ID.
438441
* @param string $notificationType
439-
* The notification type (one of the NOTIFICATION_* constannts).
442+
* The notification type (one of the NOTIFICATION_* constants).
440443
* @param array $templateTask
441444
* The Maestro template task.
442445
* @param int $maestroQueueID
443446
* The Maestro queue ID.
444447
* @param string|null $contentType
445-
* Optional content type. If not set the content type will be compoted based
448+
* Optional content type. If not set the content type will be computed based
446449
* on the recipient.
447450
*
448451
* @return array
@@ -453,13 +456,20 @@ private function sendNotificationDigitalPost(
453456
* - subject
454457
* - taskUrl (for digital post)
455458
* - actionLabel (for digital post)
459+
* - senderLabel (for digital post)
456460
*
457461
* @see self::renderHtml()
458462
*/
459463
public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, ?string $contentType = NULL): array {
460464
$handler = $submission->getWebform()->getHandler($handlerId);
461465
$settings = $handler->getSettings();
462466

467+
$senderLabel = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::SENDER_LABEL] ?? NULL;
468+
469+
if (NULL === $senderLabel) {
470+
throw new RuntimeException(sprintf('Cannot get setting for Maestro notification: %s', MaestroNotificationHandler::SENDER_LABEL));
471+
}
472+
463473
$data = $submission->getData();
464474
$recipientElement = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::RECIPIENT_ELEMENT] ?? NULL;
465475
// Handle os2forms_person_lookup element.
@@ -558,6 +568,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
558568
'subject' => $subject,
559569
'taskUrl' => $taskUrl,
560570
'actionLabel' => $actionLabel,
571+
'senderLabel' => $senderLabel,
561572
];
562573
}
563574

0 commit comments

Comments
 (0)