Public Member Functions | |
orm_CodeGen ($mapName, $projectName) | |
__construct ($mapName, $projectName) | |
getClassList () | |
Returns the List of class(s) that has been generated. | |
Data Fields | |
$__tableAliasClassList = array() | |
$__projectName | |
$__mapName | |
Private Member Functions | |
gen_class () | |
Generate the Code as string and stores it to some Buffer. | |
__write ($str) | |
Writes the generated Code to hard file. |
Definition at line 33 of file class-gen.php.
orm_CodeGen::__construct | ( | $ | mapName, | |
$ | projectName | |||
) |
Definition at line 56 of file class-gen.php.
00056 { 00057 $this->__mapName = $mapName; 00058 $this->__projectName = $projectName; 00059 parent::__construct(); 00060 parent::loadMap(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($projectName).DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$mapName.'.orm.map.php'); 00061 }
orm_CodeGen::orm_CodeGen | ( | $ | mapName, | |
$ | projectName | |||
) |
Definition at line 53 of file class-gen.php.
References ormMapParser::__construct().
00053 { 00054 $this->__construct($mapName, $projectName); 00055 }
orm_CodeGen::gen_class | ( | ) | [private] |
Generate the Code as string and stores it to some Buffer.
$projectName | string |
Definition at line 68 of file class-gen.php.
References $__ZigOrm, and __write().
00068 { 00069 global $__ZigOrm; 00070 //global $__zigOrmLoadedClassList; 00071 if(file_exists(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($this->__projectName).DRS.Z_DIR_APPS.DRS.Z_DIR_MVC_MODEL.DRS.'orm'.DRS.$this->__mapName.'.orm.php')){ 00072 include(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($this->__projectName).DRS.Z_DIR_APPS.DRS.Z_DIR_MVC_MODEL.DRS.'orm'.DRS.$this->__mapName.'.orm.php'); 00073 $this->__tableAliasClassList = $__zigOrmLoadedClassList; 00074 //$__zigOrmLoadedClassList = array();//experimental 00075 $__ZigOrm->connections[$this->__struct->connection->alias] = $this->__struct->connection; 00076 return true; 00077 } 00078 $__ZigOrm->connections[$this->__struct->connection->alias] = $this->__struct->connection; 00079 $var_str = 'var'; 00080 $fnc_str = 'function'; 00081 $parent_class = $this->__projectName.'OrmTable'; 00082 $file_str = "<?php\n/**\n *\tThis File is auto generated By Zigmoyd ORM Handler by reading the ORM Map on File $this->__map_file_name\n */\n\n"; 00083 foreach($this->__struct->tables as $table_name => $table_obj){ 00084 //{ Writting Class 00085 $file_str .= "if(!class_exists('$table_obj->alias')):"; 00086 $file_str .= "//{ Writting Class ".$table_obj->alias." for Table $table_name\n"; 00087 $this->__tableAliasClassList[] = $table_obj->alias; 00088 $file_str .= "class ".$table_obj->alias." extends $parent_class{\n"; 00089 //{{ Writting Connecion Alias 00090 $file_str .= "\t".$var_str." \$connAlias = '".$this->__struct->connection->alias."';//Connection Alias name"; 00091 $file_str .= "\n\t".$var_str." \$realTableName = '".$table_name."';//Real Table Name"; 00092 //{{{ Write the Structure 00093 $file_str .= "\n\t".$var_str." \$__struct = '".base64_encode(serialize($table_obj))."';//Writting Structure\n"; 00094 //}}} 00095 //{{{ Write The Constructor 00096 $file_str .= "\n\t".$fnc_str." $table_obj->alias"."(){\n\t\t//Writting The Constructor Method\n"; 00097 $file_str .= "\t\tif(function_exists('overload'))overload(get_class(\$this));\n"; 00098 $file_str .= "\t\t\$this->__struct = unserialize(base64_decode(\$this->__struct));\n\t\t\$this->init();\n"; 00099 $file_str .= "\t}\n"; 00100 //}}} 00101 //}} 00102 $file_str .= "}\n"; 00103 $file_str .= "//}\nendif;\nif(!class_exists('$table_obj->alias"."RowSet')):\nclass ".$table_obj->alias."RowSet extends ".$this->__projectName."OrmRowSet{\n\t//you can write your own custom Access Methods methods here 00104 \n\t$fnc_str $table_obj->alias"."RowSet(){\n\t\tif(function_exists('overload'))overload(get_class(\$this));\n\t}\n}\nendif;\n"; 00105 //} 00106 } 00107 $file_str .= "?>"; 00108 //{ add the loaded Class(Table Alias) List 00109 $listStr = "<?php\n//{Generating the List of Classes in this file\n"; 00110 foreach($this->__tableAliasClassList as $class){ 00111 $listStr .= "\$__zigOrmLoadedClassList[] = '$class';\n"; 00112 } 00113 $listStr .= "//}\n?>\n"; 00114 //} 00115 $this->__write($listStr.$file_str); 00116 }
orm_CodeGen::__write | ( | $ | str | ) | [private] |
Writes the generated Code to hard file.
For internal use only.
Doesn't generates any code
$str | string | |
$projectName | string |
Definition at line 125 of file class-gen.php.
Referenced by gen_class().
00125 { 00126 $dest_file = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($this->__projectName).DRS.Z_DIR_APPS.DRS.Z_DIR_MVC_MODEL.DRS.'orm'.DRS.$this->__mapName.'.orm.php'; 00127 file_put_contents($dest_file, $str); 00128 include_once($dest_file); 00129 }
orm_CodeGen::getClassList | ( | ) |
Returns the List of class(s) that has been generated.
Definition at line 135 of file class-gen.php.
orm_CodeGen::$__tableAliasClassList = array() |
Definition at line 39 of file class-gen.php.
orm_CodeGen::$__projectName |
Definition at line 45 of file class-gen.php.
orm_CodeGen::$__mapName |
Definition at line 51 of file class-gen.php.