Removing template code.

This commit is contained in:
mark_story 2009-05-13 23:37:21 -04:00
parent 3c08369e3a
commit 4a9a5bce69

View file

@ -705,148 +705,7 @@ class ModelTask extends Shell {
$this->Template->set('plugin', $this->plugin);
$out = $this->Template->generate('objects', 'model');
/*
$out = "<?php\n";
$out .= "class {$name} extends {$this->plugin}AppModel {\n\n";
$out .= "\tvar \$name = '{$name}';\n";
if ($useDbConfig !== 'default') {
$out .= "\tvar \$useDbConfig = '$useDbConfig';\n";
}
if (($useTable && $useTable !== Inflector::tableize($name)) || $useTable === false) {
$table = "'$useTable'";
if (!$useTable) {
$table = 'false';
}
$out .= "\tvar \$useTable = $table;\n";
}
if ($primaryKey !== 'id') {
$out .= "\tvar \$primaryKey = '$primaryKey';\n";
}
$validateCount = count($validate);
if (is_array($validate) && $validateCount > 0) {
$out .= "\tvar \$validate = array(\n";
$keys = array_keys($validate);
for ($i = 0; $i < $validateCount; $i++) {
$val = "'" . $validate[$keys[$i]] . "'";
$out .= "\t\t'" . $keys[$i] . "' => array({$val})";
if ($i + 1 < $validateCount) {
$out .= ",";
}
$out .= "\n";
}
$out .= "\t);\n";
}
$out .= "\n";
if (!empty($associations)) {
if (!empty($associations['belongsTo']) || !empty($associations['hasOne']) || !empty($associations['hasMany']) || !empty($associations['hasAndBelongsToMany'])) {
$out.= "\t//The Associations below have been created with all possible keys, those that are not needed can be removed\n";
}
if (!empty($associations['belongsTo'])) {
$out .= "\tvar \$belongsTo = array(\n";
$belongsToCount = count($associations['belongsTo']);
for ($i = 0; $i < $belongsToCount; $i++) {
$out .= "\t\t'{$associations['belongsTo'][$i]['alias']}' => array(\n";
$out .= "\t\t\t'className' => '{$associations['belongsTo'][$i]['className']}',\n";
$out .= "\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n";
$out .= "\t\t\t'conditions' => '',\n";
$out .= "\t\t\t'fields' => '',\n";
$out .= "\t\t\t'order' => ''\n";
$out .= "\t\t)";
if ($i + 1 < $belongsToCount) {
$out .= ",";
}
$out .= "\n";
}
$out .= "\t);\n\n";
}
if (!empty($associations['hasOne'])) {
$out .= "\tvar \$hasOne = array(\n";
$hasOneCount = count($associations['hasOne']);
for ($i = 0; $i < $hasOneCount; $i++) {
$out .= "\t\t'{$associations['hasOne'][$i]['alias']}' => array(\n";
$out .= "\t\t\t'className' => '{$associations['hasOne'][$i]['className']}',\n";
$out .= "\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n";
$out .= "\t\t\t'dependent' => false,\n";
$out .= "\t\t\t'conditions' => '',\n";
$out .= "\t\t\t'fields' => '',\n";
$out .= "\t\t\t'order' => ''\n";
$out .= "\t\t)";
if ($i + 1 < $hasOneCount) {
$out .= ",";
}
$out .= "\n";
}
$out .= "\t);\n\n";
}
if (!empty($associations['hasMany'])) {
$out .= "\tvar \$hasMany = array(\n";
$hasManyCount = count($associations['hasMany']);
for ($i = 0; $i < $hasManyCount; $i++) {
$out .= "\t\t'{$associations['hasMany'][$i]['alias']}' => array(\n";
$out .= "\t\t\t'className' => '{$associations['hasMany'][$i]['className']}',\n";
$out .= "\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n";
$out .= "\t\t\t'dependent' => false,\n";
$out .= "\t\t\t'conditions' => '',\n";
$out .= "\t\t\t'fields' => '',\n";
$out .= "\t\t\t'order' => '',\n";
$out .= "\t\t\t'limit' => '',\n";
$out .= "\t\t\t'offset' => '',\n";
$out .= "\t\t\t'exclusive' => '',\n";
$out .= "\t\t\t'finderQuery' => '',\n";
$out .= "\t\t\t'counterQuery' => ''\n";
$out .= "\t\t)";
if ($i + 1 < $hasManyCount) {
$out .= ",";
}
$out .= "\n";
}
$out .= "\t);\n\n";
}
if (!empty($associations['hasAndBelongsToMany'])) {
$out .= "\tvar \$hasAndBelongsToMany = array(\n";
$hasAndBelongsToManyCount = count($associations['hasAndBelongsToMany']);
for ($i = 0; $i < $hasAndBelongsToManyCount; $i++) {
$out .= "\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' => array(\n";
$out .= "\t\t\t'className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n";
$out .= "\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n";
$out .= "\t\t\t'foreignKey' => '{$associations['hasAndBelongsToMany'][$i]['foreignKey']}',\n";
$out .= "\t\t\t'associationForeignKey' => '{$associations['hasAndBelongsToMany'][$i]['associationForeignKey']}',\n";
$out .= "\t\t\t'unique' => true,\n";
$out .= "\t\t\t'conditions' => '',\n";
$out .= "\t\t\t'fields' => '',\n";
$out .= "\t\t\t'order' => '',\n";
$out .= "\t\t\t'limit' => '',\n";
$out .= "\t\t\t'offset' => '',\n";
$out .= "\t\t\t'finderQuery' => '',\n";
$out .= "\t\t\t'deleteQuery' => '',\n";
$out .= "\t\t\t'insertQuery' => ''\n";
$out .= "\t\t)";
if ($i + 1 < $hasAndBelongsToManyCount) {
$out .= ",";
}
$out .= "\n";
}
$out .= "\t);\n\n";
}
}
$out .= "}\n";
$out .= "?>";
*/
//@todo solve plugin model paths.
$filename = $this->path . Inflector::underscore($name) . '.php';
$this->out("\nBaking model class for $name...");
$this->createFile($filename, $out);