Skip to content

Commit

Permalink
SUPP0RT-1293: Allowed composite elements in Maestro notification reci…
Browse files Browse the repository at this point in the history
…pient
  • Loading branch information
jekuaitk committed Nov 8, 2023
1 parent b6dc947 commit 2b28709
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/os2forms_forloeb/src/MaestroHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
?? $data[$recipientElement]
?? NULL;

// Handle composite elements.
if ($recipient === NULL) {
if (str_contains($recipientElement, '__')) {
$keys = explode('__', $recipientElement);
$result = $data;
foreach ($keys as $key) {
if (array_key_exists($key, $result)) {
$result = $result[$key];
}
}

$recipient = $result;
}
}

if ($notificationType === self::NOTIFICATION_ESCALATION) {
$recipient = $settings[MaestroNotificationHandler::NOTIFICATION][$notificationType][MaestroNotificationHandler::NOTIFICATION_RECIPIENT] ?? NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,28 @@ private function getRecipientElements(): array {
'cvr_value_element',
'os2forms_person_lookup',
];

// Expand composite elements, NOT custom composite elements.
foreach ($elements as $key => $element) {
$orgElement = $this->getWebform()->getElement($key);

if (array_key_exists('#webform_composite_elements', $orgElement)) {
foreach ($orgElement['#webform_composite_elements'] as $compositeElement) {
// If composite element is not accessible ignore it.
if (array_key_exists('#access', $compositeElement) && !$compositeElement['#access']) {
continue;
}

if (in_array($compositeElement['#type'], $elementTypes, TRUE)) {
$elements[$compositeElement['#webform_composite_key']] = [
'#title' => (string) $compositeElement['#title'],
'#type' => $compositeElement['#type'],
];
}
}
}
}

$elements = array_filter(
$elements,
static function (array $element) use ($elementTypes) {
Expand Down

0 comments on commit 2b28709

Please sign in to comment.