You are here

function thunder_update_dependencies in Thunder 8.2

Same name and namespace in other branches
  1. 8.5 thunder.install \thunder_update_dependencies()
  2. 8.3 thunder.install \thunder_update_dependencies()
  3. 8.4 thunder.install \thunder_update_dependencies()
  4. 6.2.x thunder.install \thunder_update_dependencies()
  5. 6.0.x thunder.install \thunder_update_dependencies()
  6. 6.1.x thunder.install \thunder_update_dependencies()

Update hook dependencies.

1. Dependency on Thunder Updater module. 2. Ensure that Thunder updates come last so entity schema updates and more fundamental updates occur first.

Return value

mixed Returns list of update hook dependencies.

File

./thunder.install, line 29
Install, update and uninstall functions for the thunder installation profile.

Code

function thunder_update_dependencies() {
  $switchToUpdaterHelperUpdaterHook = [
    'thunder_updater' => 8001,
  ];
  $dependencies['thunder'] = [
    8006 => $switchToUpdaterHelperUpdaterHook,
  ];

  // Ensure that all thunder hook_update_N functions are called after all other
  // update hooks.
  $list = [];
  $return = [];
  $updates = update_get_update_list();

  // List of thunder modules with hook_update_N() functions.
  $thunder_module_list = [
    'thunder',
    'thunder_article',
    'thunder_liveblog',
    'thunder_media',
    'thunder_paragraphs',
    'thunder_taxonomy',
  ];
  foreach ($updates as $module => $info) {
    if (in_array($module, $thunder_module_list, TRUE)) {

      // Build a list of thunder modules with updates to run.
      $return[$module] = [];
    }
    else {

      // Build the list of all the update hooks for thunder updates to depend
      // on.
      $pending = array_keys($info['pending']);
      $list[$module] = array_pop($pending);
    }
  }

  // Add the dependencies to the thunder modules with updates to run.
  foreach ($return as $module => &$info) {
    $info[$updates[$module]['start']] = $list;
  }

  // Set a custom skip message for update taxonomy_update_8601(), because we
  // provide our own update path in thunder_taxonomy_update_8003().
  if (!empty($updates['taxonomy']['pending'][8601])) {
    \Drupal::state()
      ->set('taxonomy_update_8601_skip_message', 'This update function was skipped, because Thunder provides it\'s own update for the status field on taxonomy terms.');
  }
  return NestedArray::mergeDeepArray([
    $return,
    $dependencies,
  ], TRUE);
}