You are here

function patterns_check_module_dependencies in Patterns 6

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_check_module_dependencies()

Check if all the module dependencies are available

Parameters

$modules: array of module names

$update_list: if TRUE, add all the dependecies to pattern's module list

Return value

empty array if all dependencies are available array of missing module's names if some dependencies are not available

1 call to patterns_check_module_dependencies()
patterns_install_modules in ./patterns.module

File

./patterns.module, line 2781
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_check_module_dependencies(&$modules, $update_list = FALSE) {
  if (empty($modules)) {
    return array();
  }
  $modules_info = module_rebuild_cache();
  $result = array();
  $dependencies = array();
  foreach ($modules as $module) {
    $module = is_array($module) ? $module['value'] : $module;
    if (array_key_exists($module, $modules_info)) {

      // check also for module's dependencies
      foreach ($modules_info[$module]->info['dependencies'] as $dependency) {
        if (array_key_exists($dependency, $modules_info)) {
          $dependencies[] = $dependency;
        }
        else {
          $result[] = $dependency;
        }
      }
    }
    else {
      $result[] = $module;
    }
  }
  if ($update_list && empty($result) && !empty($dependencies)) {
    $modules = array_unique(array_merge($modules, $dependencies));
  }
  return $result;
}