Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions os2forms_forloeb.module
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,52 @@ function os2forms_forloeb_workflow_maestro_reassign_form_submit(&$form, &$form_s
drupal_set_message("Content Reassigned");

}

/**
* * Implements hook_maestro_batch_handlers().
* *
* * Array of function names and help text that will be displayed
* * in the edit task form under the handler field.
* */
function os2forms_forloeb_maestro_batch_handlers() {
return [
'end_notification_batch_function' => t('Batch function to send out flow completion notification to initiator.'),
];
}

/**
* * @param int $processID
* * The Maestro process ID.
* * @param int $queueID
* * The Maestro queue ID.
* */
function end_notification_batch_function($processID, $queueID) {

/*
* Pseudocode for handling this:
*
* * Get entity item for webform which spawned this process
* (ID "submission").
* foreach handler in webform: {
* if (email_handler) {
* email_handler.submit();
* }
* }
*/
$sid = MaestroEngine::getEntityIdentiferByUniqueID($processID, 'submission');

if ($sid) {
$webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid);
$webform = $webform_submission->getWebform();
$handlers = $webform->getHandlers();

foreach ($handlers as $handler) {
if (method_exists($handler, 'getMessage')) {
$message = $handler->getMessage($webform_submission);
$handler->sendMessage($webform_submission, $message);
}
}
}

return TRUE;
}