function ModuleBuilderGeneratorCode::code_body in Module Builder 6.2
Return the main body of the file code.
Overrides ModuleBuilderGenerator::code_body
File
- includes/
generate.inc, line 111 - Module builder code generating code.
Class
- ModuleBuilderGeneratorCode
- Generator class for module code files.
Code
function code_body() {
// Get old style variable names.
$module_data = $this->module_data;
$hook_data = $this->hook_data;
$code = '';
foreach ($hook_data as $hook_name => $hook) {
// Display PHP doc.
$code .= "\n" . module_builder_code_hook_doxy($hook_name);
// function declaration: put in the module name, add closing brace, decode html entities
$declaration = str_replace('hook', $module_data['module_root_name'], $hook['declaration']) . ' {';
$code .= htmlspecialchars_decode($declaration);
// See if function bodies exist; if so, use function bodies from template
if (isset($hook['template'])) {
// Strip out INFO: comments for advanced users
if (!variable_get('module_builder_detail', 0)) {
// Used to strip INFO messages out of generated file for advanced users.
$pattern = '#\\s+/\\* INFO:(.*?)\\*/#ms';
$hook['template'] = preg_replace($pattern, '', $hook['template']);
}
//dsm($hook);
$code .= $hook['template'];
}
else {
$code .= "\n\n";
}
$code .= "}\n\n";
}
// foreach hook
// Replace variables
$variables = array(
'%module' => $module_data['module_root_name'],
'%description' => str_replace("'", "\\'", $module_data['module_short_description']),
'%name' => !empty($module_data['module_readable_name']) ? str_replace("'", "\\'", $module_data['module_readable_name']) : $module_data['module_root_name'],
'%help' => !empty($module_data['module_help_text']) ? str_replace('"', '\\"', $module_data['module_help_text']) : t('TODO: Create admin help text.'),
'%readable' => str_replace("'", "\\'", $module_data['module_readable_name']),
);
$code = strtr($code, $variables);
return $code;
}