class ModuleBuilderGeneratorCode in Module Builder 6.2
Generator class for module code files.
Hierarchy
- class \ModuleBuilderGenerator
- class \ModuleBuilderGeneratorCode
Expanded class hierarchy of ModuleBuilderGeneratorCode
File
- includes/
generate.inc, line 106 - Module builder code generating code.
View source
class ModuleBuilderGeneratorCode extends ModuleBuilderGenerator {
function __construct($module_data) {
$this->module_data = $module_data;
}
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;
}
/**
* Return a file footer.
*/
function code_footer() {
$footer = variable_get('module_builder_footer', '');
return $footer;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ModuleBuilderGenerator:: |
function | The main code building function. | ||
ModuleBuilderGenerator:: |
function | Return the file doxygen header and any custom header code. | 1 | |
ModuleBuilderGenerator:: |
function | Return the PHP file header line. | 1 | |
ModuleBuilderGeneratorCode:: |
function |
Return the main body of the file code. Overrides ModuleBuilderGenerator:: |
||
ModuleBuilderGeneratorCode:: |
function |
Return a file footer. Overrides ModuleBuilderGenerator:: |
||
ModuleBuilderGeneratorCode:: |
function |
Overrides ModuleBuilderGenerator:: |