You are here

function varbase_core_update_8609 in Varbase Core 8.8

Same name and namespace in other branches
  1. 8.6 varbase_core.install \varbase_core_update_8609()
  2. 8.7 varbase_core.install \varbase_core_update_8609()
  3. 9.0.x varbase_core.install \varbase_core_update_8609()

Rename config updates in Varbase Update Helper to match with new.

Update ids standard naming conventions.

File

./varbase_core.install, line 217
Install, update and uninstall functions for the Varbase core module.

Code

function varbase_core_update_8609() {

  // Mapping old update ids naming conventions.
  $map_old_to_new_update_ids = [
    'varbase_core:varbase_admin_vbo_8601' => 'varbase_core:varbase_core_optional_update_8601',
    'varbase_core:varbase_media_blazy_8602' => 'varbase_core:varbase_core_optional_update_8602',
    'varbase_core:varbase_email_enable_8603' => 'varbase_core:varbase_core_optional_update_8603',
    'varbase_core:varbase_page_li_8604' => 'varbase_core:varbase_core_optional_update_8604',
    'varbase_core:varbase_landing_li_8605' => 'varbase_core:varbase_core_optional_update_8605',
    'varbase_core:varbase_heroslider_media_li_8606' => 'varbase_core:varbase_core_optional_update_8606',
    'varbase_core:varbase_blog_li_8607' => 'varbase_core:varbase_core_optional_update_8607',
    'varbase_core:varbase_media_bs3_to_bs4_8608' => 'varbase_core:varbase_core_update_8608',
  ];

  // Check the old update ids and change them with new update ids.
  foreach ($map_old_to_new_update_ids as $old_update_id => $new_update_id) {

    // If we do have the old update id in the system.
    if ($old_update = Update::load($old_update_id)) {

      // Create the new update id if it was not in the system.
      $new_update = Update::load($new_update_id);
      if (isset($new_update) && !$new_update) {
        Update::create([
          'id' => $new_update_id,
          'successful_by_hook' => $old_update
            ->get('successful_by_hook'),
        ])
          ->save();
      }

      // Delete old update id.
      $old_update
        ->delete();
    }
  }
}