You are here

public function DrupalModulesManager::findDependencies in Configuration Management 7.3

File

src/Helpers/DrupalModulesManager.php, line 36

Class

DrupalModulesManager

Namespace

Configuration\Helpers

Code

public function findDependencies($modules) {
  $status = array();
  $this
    ->getAllModules();
  $not_proccesed_yet = $modules;
  while (count($not_proccesed_yet) > 0) {
    $module = array_pop($not_proccesed_yet);
    if (!empty($status[$module])) {
      continue;
    }
    if (!isset($this->modules[$module])) {
      $this->missing[] = $module;
    }
    else {
      if (!empty($this->modules[$module]->status)) {
        $this->enabled[] = $module;
      }
      else {
        $this->to_enable[] = $module;
      }

      // Add the dependencies of the current module to discover new dependencies
      foreach ($this->modules[$module]->requires as $dependency => $value) {
        if (!isset($this->modules[$dependency])) {
          $not_proccesed_yet[] = $dependency;
        }
      }
    }
  }
  return $status;
}