function patterns_install_modules in Patterns 7
Same name and namespace in other branches
- 6.2 patterns.module \patterns_install_modules()
- 6 patterns.module \patterns_install_modules()
- 7.2 includes/core/modules.inc \patterns_install_modules()
Installs required modules for executing the pattern, if they are not already enabled.
Returns an associative array containing information about which modules have been actually installed.
Parameters
array $modules The list of modules name to install.:
2 calls to patterns_install_modules()
- patterns_install_modules_in_pattern in ./
patterns.module - Extract all the values of the modules tag from a pattern and returns them as an array.
- patterns_start_engine in ./
patterns.module - The beginning of the whole Patterns logic. Starts the execution in 'batch' mode (default) or 'php' mode, which makes things easier for debugging.
File
- includes/
core/ modules.inc, line 21 - Functions to install and uninstall modules during the pattern execution.
Code
function patterns_install_modules(&$modules) {
$result = array();
$result['success'] = TRUE;
$result['installed_modules'] = array();
if (empty($modules)) {
return $result;
}
$to_install = patterns_check_modules_to_install($modules);
if (!empty($to_install['missing'])) {
$result['success'] = FALSE;
$result['error_message'] = t('Following required modules are missing: %modules', array(
'%modules' => implode(', ', $to_install['missing']),
));
$result['missing_modules'] = $to_install['missing'];
return $result;
}
if (!empty($to_install['to_install'])) {
return $result;
}
require_once DRUPAL_ROOT . '/' . 'includes/install.inc';
$result['success'] = module_enable($to_install['to_install'], TRUE);
system_rebuild_module_data();
$result['installed_modules'] = $to_install['to_install'];
return $result;
}