Verifies that all dependencies are met for a given installation profile.
$install_state: An array of information about the current installation state.
The list of modules to install.
function drupal_verify_profile($install_state) {
include_once DRUPAL_ROOT . '/core/includes/file.inc';
include_once DRUPAL_ROOT . '/core/includes/common.inc';
$profile = $install_state['parameters']['profile'];
$profile_file = $install_state['profiles'][$profile]->uri;
if (!isset($profile) || !file_exists($profile_file)) {
throw new Exception(install_no_profile_error());
}
$info = $install_state['profile_info'];
// Get a list of modules that exist in Drupal's assorted subdirectories.
$present_modules = array();
foreach (drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\\.module$/', 'modules') as $present_module) {
$present_modules[] = $present_module->name;
}
// The installation profile is also a module, which needs to be installed
// after all the other dependencies have been installed.
$present_modules[] = drupal_get_profile();
// Verify that all of the profile's required modules are present.
$missing_modules = array_diff($info['dependencies'], $present_modules);
$requirements = array();
if (count($missing_modules)) {
$modules = array();
foreach ($missing_modules as $module) {
$modules[] = '<span class="admin-missing">' . drupal_ucfirst($module) . '</span>';
}
$requirements['required_modules'] = array(
'title' => st('Required modules'),
'value' => st('Required modules not found.'),
'severity' => REQUIREMENT_ERROR,
'description' => st('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: !modules', array(
'!modules' => implode(', ', $modules),
)),
);
}
return $requirements;
}