function maestro_update_8001 in Maestro 8.2
Same name and namespace in other branches
- 3.x maestro.install \maestro_update_8001()
Update 8001 - Create maestro_process_status entity.
File
- ./
maestro.install, line 16 - Install, update and uninstall functions for the Maestro module.
Code
function maestro_update_8001() {
// Check if the table exists first. If not, then create the entity.
if (\Drupal::service('database')
->schema()
->tableExists('maestro_process_status') === FALSE) {
\Drupal::entityTypeManager()
->clearCachedDefinitions();
\Drupal::entityDefinitionUpdateManager()
->installEntityType(\Drupal::entityTypeManager()
->getDefinition('maestro_process_status'));
// Now add the required variables to each of the templates. Existing in-production templates will not be affected.
$templates = MaestroEngine::getTemplates();
foreach ($templates as $template) {
$variables = $template->variables;
if (!array_key_exists('workflow_timeline_stage_count', $variables)) {
$template->variables['workflow_timeline_stage_count'] = [
'variable_id' => 'workflow_timeline_stage_count',
'variable_value' => '',
];
}
if (!array_key_exists('workflow_current_stage', $variables)) {
$template->variables['workflow_current_stage'] = [
'variable_id' => 'workflow_current_stage',
'variable_value' => '',
];
}
if (!array_key_exists('workflow_current_stage_message', $variables)) {
$template->variables['workflow_current_stage_message'] = [
'variable_id' => 'workflow_current_stage_message',
'variable_value' => '',
];
}
$template
->save();
}
}
else {
return 'Process Status entity already exists';
}
}