You are here

function _node_gallery_check_dependencies in Node Gallery 7

Check dependencies for Node Gallery. Code adapted from module_enable().

Parameters

$module_list:

Throws

DrupalUpdateException

1 call to _node_gallery_check_dependencies()
node_gallery_update_7001 in ./node_gallery.install
Enable the node_gallery_api module to create its database tables.

File

./node_gallery.install, line 186
Install, update and uninstall functions for the node_gallery module.

Code

function _node_gallery_check_dependencies($module_list) {

  // Get all module data so we can find dependencies and sort.
  $module_data = system_rebuild_module_data();

  // Create an associative array with weights as values.
  $module_list = array_flip(array_values($module_list));
  foreach ($module_list as $module) {
    if (!isset($module_data[$module])) {

      // This module is not found in the filesystem, throw an exception.
      $t = get_t();
      throw new DrupalUpdateException($t('Node Gallery (node_gallery) requires that @module module is installed. Install this module and run the update again.', array(
        '@module' => $module,
      )));
    }
    if ($module_data[$module]->status) {

      // Skip already enabled modules.
      unset($module_list[$module]);
      continue;
    }
    $module_list[$module] = $module_data[$module]->sort;

    // Add dependencies to the list, with a placeholder weight.
    // The new modules will be processed as the while loop continues.
    foreach (array_keys($module_data[$module]->requires) as $dependency) {
      if (!isset($module_list[$dependency])) {
        $module_list[$dependency] = 0;
      }
    }
  }
}