You are here

abstract class ModuleBuilderGenerator in Module Builder 6.2

Base class for code generators.

TODO: much more of the code generation could be moved to OO code:

  • pass all hook data to one code generator object, representing the .module

file, which then instantiates further objects for the other files needed. This would probably entail a controller object which can hold the list of current generators.

  • templates.

Hierarchy

Expanded class hierarchy of ModuleBuilderGenerator

1 string reference to 'ModuleBuilderGenerator'
module_builder_get_class in includes/generate.inc
Helper function to get the desired class.

File

includes/generate.inc, line 50
Module builder code generating code.

View source
abstract class ModuleBuilderGenerator {
  function __construct($module_data) {
    $this->module_data = $module_data;
  }

  /**
   * The main code building function.
   */
  function build() {
    $output = '';
    $output .= $this
      ->file_header();
    $output .= $this
      ->code_header();
    $output .= $this
      ->code_body();
    $output .= $this
      ->code_footer();
    return $output;
  }

  /**
   * Return the PHP file header line.
   */
  function file_header() {
    return "<?php\n";
  }

  /**
   * Return the file doxygen header and any custom header code.
   */
  function code_header() {
    $filename = $this->filename;
    $default = <<<EOT
/**
 * @file {<span class="php-variable">$filename</span>}
 * TODO: Enter file description here.
 */

EOT;
    $code = variable_get('module_builder_header', $default);
    return $code;
  }

  /**
   * Return the main body of the file code.
   */
  abstract function code_body();

  /**
   * Return a file footer.
   */
  function code_footer() {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ModuleBuilderGenerator::build function The main code building function.
ModuleBuilderGenerator::code_body abstract function Return the main body of the file code. 2
ModuleBuilderGenerator::code_footer function Return a file footer. 1
ModuleBuilderGenerator::code_header function Return the file doxygen header and any custom header code. 1
ModuleBuilderGenerator::file_header function Return the PHP file header line. 1
ModuleBuilderGenerator::__construct function 1