function maestro_update_8005 in Maestro 3.x
Same name and namespace in other branches
- 8.2 maestro.install \maestro_update_8005()
Update 8005 - Create new view for Maestro Entity Identifiers "Items Attached to Workflow" and configure each template to use 2 views.
File
- ./
maestro.install, line 132 - Install, update and uninstall functions for the Maestro module.
Code
function maestro_update_8005() {
$message = NULL;
if (\Drupal::moduleHandler()
->moduleExists('views') && !View::load('maestro_entity_identifiers')) {
$config_path = drupal_get_path('module', 'maestro') . '/config/install/views.view.maestro_entity_identifiers.yml';
$data = Yaml::parse(file_get_contents($config_path));
\Drupal::configFactory()
->getEditable('views.view.maestro_entity_identifiers')
->setData($data)
->save(TRUE);
$message = 'The new Maestro Entity Identifiers view for the Task Console has been created.';
}
else {
$message = 'Not creating the Maestro Entity Identifiers "Items Attached to Workflow" view since it already exists.';
}
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$templates = MaestroEngine::getTemplates();
foreach ($templates as $template) {
$template->views_attached = [
'maestro_completed_tasks' => [
'view_machine_name' => 'maestro_completed_tasks',
'view_weight' => -9,
'view_display' => 'default;Master',
],
'maestro_entity_identifiers' => [
'view_machine_name' => 'maestro_entity_identifiers',
'view_weight' => -10,
'view_display' => 'taskconsole_display;Task Console Display',
],
];
$template
->save();
}
return $message;
}