Exemple #1
0
 public function generateClass()
 {
     echo "generating classes for " . $this->name . "\n";
     $smarty = new OzoneSmarty();
     $smarty->left_delimiter = '<{';
     $smarty->right_delimiter = '}>';
     $smarty->assign('className', $this->getNameLowercaseFirstCapitalized());
     $smarty->assign('tableName', $this->name);
     // put columns into context
     $smarty->assign('columns', $this->columns);
     //primary key name
     $smarty->assign('primaryKeyName', $this->pkColumnName);
     // peer name
     $peerName = "DB_" . $this->getNameLowercaseFirstCapitalized() . "Peer";
     $smarty->assign('peerName', $peerName);
     //default values
     $defvals = array();
     foreach ($this->columns as $column) {
         if ($column->getDefaultValue() != null) {
             $key = $column->getName();
             $defvals["{$key}"] = $column->getDefaultValue();
         }
     }
     $smarty->assign('defaultValues', $defvals);
     // references
     $smarty->assign('masterRelations', $this->masterRelations);
     $smarty->assign('foreignRelations', $this->foreignRelations);
     $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ObjectBaseTemplate.tpl";
     $out = $smarty->fetch($templateFile);
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'Base';
     file_put_contents(PathManager::dbClass('/base/' . $cn), $out);
     //see if file exists!
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized();
     if (!file_exists(PathManager::dbClass($cn))) {
         $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ObjectTemplate.tpl";
         $out = $smarty->fetch($templateFile);
         file_put_contents(PathManager::dbClass($cn), $out);
     }
     $objectName = "DB_" . $this->getNameLowercaseFirstCapitalized();
     $smarty->assign('objectName', $objectName);
     $templateFilePeer = OZONE_ROOT . "/files/dbtemplates/DB_ObjectPeerBaseTemplate.tpl";
     $out = $smarty->fetch($templateFilePeer);
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'PeerBase';
     file_put_contents(PathManager::dbClass('/base/' . $cn), $out);
     //see if file exists!
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'Peer';
     if (!file_exists(PathManager::dbClass($cn))) {
         $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ObjectPeerTemplate.tpl";
         $out = $smarty->fetch($templateFile);
         file_put_contents(PathManager::dbClass($cn), $out);
     }
 }
Exemple #2
0
 public function generateClass()
 {
     echo "generating classes for " . $this->name . " view\n";
     $smarty = new OzoneSmarty();
     $smarty->assign('stringHelper', new StringHelper());
     $smarty->left_delimiter = '<{';
     $smarty->right_delimiter = '}>';
     $smarty->assign('className', $this->getNameLowercaseFirstCapitalized());
     $smarty->assign('tableName', $this->name);
     // put columns into context
     $smarty->assign('columns', $this->columnNames);
     // peer name
     $peerName = "DB_" . $this->getNameLowercaseFirstCapitalized() . "Peer";
     $smarty->assign('peerName', $peerName);
     $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ViewBaseTemplate.tpl";
     $out = $smarty->fetch($templateFile);
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'Base';
     file_put_contents(PathManager::dbClass('/base/' . $cn), $out);
     //see if file exists!
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized();
     if (!file_exists(PathManager::dbClass($cn))) {
         $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ViewTemplate.tpl";
         $out = $smarty->fetch($templateFile);
         file_put_contents(PathManager::dbClass($cn), $out);
     }
     $objectName = "DB_" . $this->getNameLowercaseFirstCapitalized();
     $smarty->assign('objectName', $objectName);
     $templateFilePeer = OZONE_ROOT . "/files/dbtemplates/DB_ViewPeerBaseTemplate.tpl";
     $out = $smarty->fetch($templateFilePeer);
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'PeerBase';
     file_put_contents(PathManager::dbClass('/base/' . $cn), $out);
     //see if file exists!
     $cn = 'DB_' . $this->getNameLowercaseFirstCapitalized() . 'Peer';
     if (!file_exists(PathManager::dbClass($cn))) {
         $templateFile = OZONE_ROOT . "/files/dbtemplates/DB_ViewPeerTemplate.tpl";
         $out = $smarty->fetch($templateFile);
         file_put_contents(PathManager::dbClass($cn), $out);
     }
 }