You are here

function profile_module_manager_build_ideal in Profile Module Manager 7.2

Same name and namespace in other branches
  1. 7 profile_module_manager.module \profile_module_manager_build_ideal()

Returns an array of core modules.

Return value

array

1 call to profile_module_manager_build_ideal()
profile_module_manager_is_config_ideal in ./profile_module_manager.module
Returns an array of projects that are enabled, but not ignored.

File

./profile_module_manager.module, line 213
Alters grouping in admin/modules using hook_system_info_alter

Code

function profile_module_manager_build_ideal() {
  $new_ideal = array();
  require_once DRUPAL_ROOT . '/includes/install.inc';
  $profile_name = drupal_get_profile();
  $profile = install_profile_info($profile_name);

  // Start with the profile
  $ideal = isset($profile['dependencies']) ? $profile['dependencies'] : array();
  $ignore = isset($profile['optional-dependencies']) ? $profile['optional-dependencies'] : array();

  // Add core dependencies to ideal and ignore arrays.
  $core_modules = profile_module_manager_get_core_modules('enabled');
  foreach ($core_modules as $core) {

    // could just replace .module w/ .info from $bundle->filename
    // which is faster?
    $path = drupal_get_path('module', $core->name) . '/' . $core->name . '.info';
    $info = drupal_parse_info_file($path);
    if (isset($info['dependencies'])) {
      $ideal = array_merge($ideal, $info['dependencies']);
    }
    if (isset($info['optional-dependencies'])) {
      $ignore = array_merge($ignore, $info['optional-dependencies']);
    }

    // and the core itself
    $ideal[] = $core->name;
  }

  // Add enabled bundle dependencies to ideal and ignore arrays.
  $bundles = profile_module_manager_get_bundles('enabled');
  foreach ($bundles as $bundle) {

    // could just replace .module w/ .info from $bundle->filename
    // which is faster?
    $path = drupal_get_path('module', $bundle->name) . '/' . $bundle->name . '.info';
    $info = drupal_parse_info_file($path);
    if (isset($info['dependencies'])) {
      $ideal = array_merge($ideal, $info['dependencies']);
    }
    if (isset($info['optional-dependencies'])) {
      $ignore = array_merge($ignore, $info['optional-dependencies']);
    }

    // and the bundle itself
    $ideal[] = $bundle->name;
  }

  // rebuild ideal so keys = value and ignore optional dependencies
  foreach ($ideal as $item) {
    $new_ideal[$item] = $item;
  }

  // add any ignored project to new_ideal
  foreach ($ignore as $item) {
    if (module_exists($item)) {
      $new_ideal[$item] = $item;
    }
  }

  // add the profile itself to the list
  $new_ideal[$profile_name] = $profile_name;
  return $new_ideal;
}