Skip to content
Snippets Groups Projects
Commit 09cc99fc authored by Randy Kolenko's avatar Randy Kolenko
Browse files

Issue #3521204: Updater for existing view for Maestro Completed Tasks.

parent 6f7a0c51
No related branches found
No related tags found
No related merge requests found
Pipeline #482045 passed with warnings
......@@ -315,7 +315,7 @@ function maestro_update_10003() {
$view_yml_file = $module_path . '/config/install/' . $view_file;
// Check if the file exists.
if (file_exists($view_yml_file)) { // skip this for now
if (file_exists($view_yml_file)) {
// Load the YAML content.
$yaml_content = file_get_contents($view_yml_file);
......@@ -350,4 +350,56 @@ function maestro_update_10003() {
// Now clear the discovery cache to let views pick up the new filter plugin
\Drupal::cache('discovery')->deleteAll();
}
/**
* Update views configuration for Maestro Views Based Task Console.
* Update the Maestro Completed Tasks view to add in a proper reference to the Process Entity
*/
function maestro_update_10004() {
$module_path = \Drupal::service('extension.list.module')->getPath('maestro');
$views_files = [
'views.view.maestro_completed_tasks.yml',
];
foreach($views_files as $view_file) {
$view_yml_file = $module_path . '/config/install/' . $view_file;
// Check if the file exists.
// Check if the file exists.
if (file_exists($view_yml_file)) {
// Load the YAML content.
$yaml_content = file_get_contents($view_yml_file);
try {
// Remove the old view
$old_view = \Drupal::configFactory()->getEditable('views.view.maestro_completed_tasks');
if ($old_view) {
$old_view->delete();
}
$view_config = Yaml::parse($yaml_content);
if ($view_config) {
// Gen a UUID if it doesn't exist.
if (empty($view_config['uuid'])) {
$view_config['uuid'] = \Drupal::service('uuid')->generate();
}
// Save the configuration to the active storage.
\Drupal::configFactory()->getEditable('views.view.' . $view_config['id'])
->setData($view_config)
->save();
}
else {
\Drupal::logger('maestro')->error('Failed to parse YAML file: @file', ['@file' => $view_yml_file]);
}
}
catch (\Exception $e) {
\Drupal::logger('maestro')->error('Error parsing YAML file: @file. Message: @message', [
'@file' => $view_yml_file,
'@message' => $e->getMessage(),
]);
}
}
else {
\Drupal::logger('maestro')->error('YAML file not found: @file', ['@file' => $view_yml_file]);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment