function maestro_maestro_post_production_assignments in Maestro 8.2
Same name and namespace in other branches
- 3.x maestro.module \maestro_maestro_post_production_assignments()
Implements hook_maestro_post_production_assignments().
File
- ./
maestro.module, line 129 - Provides glue logic, hook implementation and core set process variable functions.
Code
function maestro_maestro_post_production_assignments($templateMachineName, $taskID, $queueID) {
global $base_url;
// For our Maestro implementation, we are concerned only with the content type task
// We need to detect if there is an already existing task that has created a piece of content
// that matches the unique_id and content type. If so, we alter the handler from the
// default handler the task template provided to a handler that allows the console to edit the existing
// content and still tack on the appropriate maestro hooks.
$task = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskID);
if ($task['tasktype'] == 'MaestroContentType') {
// let's see if this process has any variables that align to the template task's uniqueID requirements for the content type task.
$processID = MaestroEngine::getProcessIdFromQueueId($queueID);
$uniqueIdentifier = $task['data']['unique_id'];
$contentType = $task['data']['content_type'];
$entityIdentifier = MaestroEngine::getEntityIdentiferByUniqueID($processID, $uniqueIdentifier);
if ($entityIdentifier) {
// We have a match. adjust the queue item's handler to suit.
$queueRecord = \Drupal::entityTypeManager()
->getStorage('maestro_queue')
->load($queueID);
if (isset($task['data']['link_to_edit']) && $task['data']['link_to_edit'] == 1) {
$queueRecord
->set('handler', $base_url . '/node/' . intval($entityIdentifier) . '/edit?maestro=1&queueid=' . $queueID);
}
else {
$queueRecord
->set('handler', $base_url . '/node/' . intval($entityIdentifier) . '?maestro=1');
}
$queueRecord
->save();
}
}
}