@@ -257,13 +257,14 @@ private function sendNotification(
257257 'subject ' => $ subject ,
258258 'taskUrl ' => $ taskUrl ,
259259 'actionLabel ' => $ actionLabel ,
260+ 'senderLabel ' => $ senderLabel ,
260261 ] = $ this ->renderNotification ($ submission , $ handler ->getHandlerId (), $ notificationType , $ templateTask , $ maestroQueueID );
261262
262263 if ('email ' === $ contentType ) {
263264 $ this ->sendNotificationEmail ($ recipient , $ subject , $ content , $ submission , $ notificationType );
264265 }
265266 else {
266- $ this ->sendNotificationDigitalPost ($ recipient , $ subject , $ content , $ taskUrl , $ actionLabel , $ submission , $ notificationType );
267+ $ this ->sendNotificationDigitalPost ($ recipient , $ subject , $ content , $ taskUrl , $ actionLabel , $ submission , $ notificationType, $ senderLabel );
267268 }
268269 }
269270 }
@@ -313,7 +314,9 @@ private function loadQueue(): QueueInterface {
313314 * @param \Drupal\webform\WebformSubmissionInterface $submission
314315 * The webform submission.
315316 * @param string $notificationType
316- * The notification type (one of the NOTIFICATION_* constannts).
317+ * The notification type (one of the NOTIFICATION_* constants).
318+ * @param string $senderLabel
319+ * The sender label.
317320 */
318321 private function sendNotificationEmail (
319322 string $ recipient ,
@@ -388,6 +391,7 @@ private function sendNotificationDigitalPost(
388391 string $ actionLabel ,
389392 WebformSubmissionInterface $ submission ,
390393 string $ notificationType ,
394+ string $ senderLabel ,
391395 ): void {
392396 try {
393397 $ document = new Document (
@@ -396,7 +400,6 @@ private function sendNotificationDigitalPost(
396400 $ subject . '.pdf '
397401 );
398402
399- $ senderLabel = $ subject ;
400403 $ messageLabel = $ subject ;
401404
402405 // Remove all non-digits from recipient identifier.
@@ -449,13 +452,13 @@ private function sendNotificationDigitalPost(
449452 * @param string $handlerId
450453 * The handler ID.
451454 * @param string $notificationType
452- * The notification type (one of the NOTIFICATION_* constannts ).
455+ * The notification type (one of the NOTIFICATION_* constants ).
453456 * @param array $templateTask
454457 * The Maestro template task.
455458 * @param int $maestroQueueID
456459 * The Maestro queue ID.
457460 * @param string|null $contentType
458- * Optional content type. If not set the content type will be compoted based
461+ * Optional content type. If not set the content type will be computed based
459462 * on the recipient.
460463 *
461464 * @return array
@@ -466,13 +469,20 @@ private function sendNotificationDigitalPost(
466469 * - subject
467470 * - taskUrl (for digital post)
468471 * - actionLabel (for digital post)
472+ * - senderLabel (for digital post)
469473 *
470474 * @see self::renderHtml()
471475 */
472476 public function renderNotification (WebformSubmissionInterface $ submission , string $ handlerId , string $ notificationType , array $ templateTask , int $ maestroQueueID , ?string $ contentType = NULL ): array {
473477 $ handler = $ submission ->getWebform ()->getHandler ($ handlerId );
474478 $ settings = $ handler ->getSettings ();
475479
480+ $ senderLabel = $ settings [MaestroNotificationHandler::NOTIFICATION ][MaestroNotificationHandler::SENDER_LABEL ] ?? NULL ;
481+
482+ if (NULL === $ senderLabel ) {
483+ throw new RuntimeException (sprintf ('Cannot get setting for Maestro notification: %s ' , MaestroNotificationHandler::SENDER_LABEL ));
484+ }
485+
476486 $ data = $ submission ->getData ();
477487 $ recipientElement = $ settings [MaestroNotificationHandler::NOTIFICATION ][MaestroNotificationHandler::RECIPIENT_ELEMENT ] ?? NULL ;
478488 // Handle os2forms_person_lookup element.
@@ -571,6 +581,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
571581 'subject ' => $ subject ,
572582 'taskUrl ' => $ taskUrl ,
573583 'actionLabel ' => $ actionLabel ,
584+ 'senderLabel ' => $ senderLabel ,
574585 ];
575586 }
576587
0 commit comments