function maestro_form_approval_example_maestro_task_console_interactive_link_alter in Maestro 3.x
Same name and namespace in other branches
- 8.2 modules/examples/maestro_form_approval_example/maestro_form_approval_example.module \maestro_form_approval_example_maestro_task_console_interactive_link_alter()
Implements hook_maestro_task_console_interactive_link_alter().
File
- modules/
examples/ maestro_form_approval_example/ maestro_form_approval_example.module, line 171 - You need this if you want to simply use MaestroEngine in code calls as we do.
Code
function maestro_form_approval_example_maestro_task_console_interactive_link_alter(&$link, array $templateTask, $queueRecord, $templateMachineName) {
/*
* We have the link, the task detail record, queue record and the templateName available to us to alter the link
* First, we should check if this is the workflow or template that we want to change
* the active task action for, else we will affect all tasks.
*/
if ($templateMachineName == 'form_approval_flow') {
$processID = $queueRecord->process_id
->getString();
$processVariable = MaestroEngine::getProcessVariable('rejected', $processID);
if ($processVariable == '0' && $templateTask['id'] == 'submit_request') {
// The task is our submit request AND we have a process variable set means it was either saved and not completed or rejected by the manager.
$link = 'Create your request';
}
elseif ($processVariable == '1' && $templateTask['id'] == 'submit_request') {
// First time through.
$link = 'Your request was rejected. Please edit and resubmit';
}
// The second task we have for a manager is the approval task. We can alter that link text too.
if ($templateTask['id'] == 'manager_approval') {
$link = 'Manager Approval';
}
}
}