3 class ORMRootGenerator
extends class_generator
{
7 public function __construct() {
8 $this->classname
= 'BaseObject';
12 public function generate($skip_generated_note = false) {
13 parent
::generate($skip_generated_note);
15 $this->variable( '_table', null, 'protected' );
16 $this->variable( 'export', array('key'), 'protected' );
17 $this->variable( 'rewrite_columns', array(), 'static public' );
18 $this->generate_export();
19 $this->generate_construct();
20 $this->finish_class();
23 private function generate_construct() {
24 $this->init_function( "__construct", array( 'values', 'prefix', 'export' ) );
25 $this->finish_function();
28 private function generate_export() {
29 $this->init_function('export');
30 $this->write( '$result=array();');
31 $this->write( 'foreach( $this->export as $field) {' );
32 $this->write( 'if(is_callable(array($this, "get_$field"))) {');
33 $this->write( '$value = $this->{"get_$field"}();');
34 $this->write( 'if( $value instanceof Object'.self
::$model_suffix.' ) {');
35 $this->write( '$value = $value->export();');
37 $this->write( '$result[$field] = $value;');
40 $this->write( 'return $result;');
41 $this->finish_function();