function maestro_form_approval_example_manager_approval_form_submit in Maestro 8.2
Same name and namespace in other branches
- 3.x modules/examples/maestro_form_approval_example/maestro_form_approval_example.module \maestro_form_approval_example_manager_approval_form_submit()
This is the submit handler passed off to us from the Maestro Engine.
File
- modules/
examples/ maestro_form_approval_example/ maestro_form_approval_example.module, line 129 - You need this if you want to simply use MaestroEngine in code calls as we do.
Code
function maestro_form_approval_example_manager_approval_form_submit(array &$form, FormStateInterface &$form_state, $queueID = 0) {
// In our custom submit handler, **WE** are responsible for telling the engine what to do.
// This is a pretty simple process by just using the API to tell the engine to complete the task
// However, we can also set "fancy" status like cancelling as we've done here by detecting
// if the submit button was hit or not.
$queueID = intval($form_state
->getValue('maestro_queue_id'));
$triggeringElement = $form_state
->getTriggeringElement();
if (strstr($triggeringElement['#id'], 'edit-submit') !== FALSE && $queueID > 0) {
MaestroEngine::completeTask($queueID, \Drupal::currentUser()
->id());
}
else {
// we'll complete the task, but we'll also flag it as TASK_STATUS_CANCEL.
MaestroEngine::completeTask($queueID, \Drupal::currentUser()
->id());
MaestroEngine::setTaskStatus($queueID, TASK_STATUS_CANCEL);
}
}