function module_builder_generate_info in Module Builder 7
Same name in this branch
- 7 includes/generate_info_6.inc \module_builder_generate_info()
- 7 includes/generate_info_5.inc \module_builder_generate_info()
- 7 includes/generate_info_7.inc \module_builder_generate_info()
Same name and namespace in other branches
- 6.2 includes/generate_info_6.inc \module_builder_generate_info()
- 6.2 includes/generate_info_5.inc \module_builder_generate_info()
- 6.2 includes/generate_info_7.inc \module_builder_generate_info()
Generate module info file code.
Parameters
$module_data: Same as for generate_module(). An associative array of data for the module. The keys can *mostly* be taken straight from form values. They are as follows:
- 'module_root_name'
- 'module_readable_name'
- 'module_short_description'
- 'module_help_text'
- 'hooks': An associative array whose keys are full hook names (eg 'hook_menu'), where requested hooks have a value of TRUE. Unwanted hooks may also be included as keys provided their value is FALSE.
- 'module_dependencies': a string of dependencies, eg 'forum views'.
- 'module_package': the module package.
3 calls to module_builder_generate_info()
- module_builder_callback_info in drush/
module_builder.drush.inc - Handles the callback for info code generation.
- module_builder_page_generate in includes/
module_builder.pages.inc - page 2: generate code
- Xmodule_builder_page_module in ./
module_builder.module - Module form: 'module' step. Generate the module code.
File
- includes/
generate_info_7.inc, line 25 - Module builder code generating code specific to Drupal 7.
Code
function module_builder_generate_info($module_data) {
//print_r($module_data);
// Some defaults
$module_data_defaults = array(
'module_short_description' => 'TODO: Description of module',
'module_readable_name' => ucfirst(str_replace('_', ' ', $module_data['module_root_name'])),
);
foreach ($module_data as $key => $data) {
if (!$data) {
$module_data[$key] = $module_data_defaults[$key];
}
}
// The weird syntax stops this from getting mangled by CVS
$info = '; $' . 'Id$' . "\n";
$info .= 'name = ' . $module_data['module_readable_name'] . "\n";
$info .= 'description = ' . $module_data['module_short_description'] . "\n";
if (!empty($module_data['module_dependencies'])) {
foreach (explode(' ', $module_data['module_dependencies']) as $dep) {
$info .= 'dependencies[] = ' . $dep . "\n";
}
}
if (!empty($module_data['module_package'])) {
$info .= 'package = ' . $module_data['module_package'] . "\n";
}
$info .= "core = 7.x\n";
if (is_array($module_data['module_files'])) {
foreach ($module_data['module_files'] as $file) {
$info .= 'files[] = ' . $file . "\n";
}
}
return $info;
}