Skip to content

Commit

Permalink
Cleaning up model template.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 14, 2009
1 parent 4a9a5bc commit a85bf16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cake/console/libs/templates/objects/model.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

echo "<?php\n"; ?>

class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
var $name = '<?php echo $name; ?>';
<?php if ($useDbConfig != 'default'): ?>
Expand All @@ -32,11 +33,11 @@ class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
$table = 'false';
endif;
echo "\tvar \$useTable = $table;\n";
endif; ?>
<?php if ($primaryKey !== 'id'): ?>
endif;
if ($primaryKey !== 'id'): ?>
var $primaryKey = '<?php echo $primaryKey; ?>';
<?php endif; ?>
<?php
<?php endif;

if (!empty($validate)):
echo "\tvar \$validate = array(\n";
foreach ($validate as $field => $validations):
Expand All @@ -47,7 +48,11 @@ if (!empty($validate)):
echo "\t\t),\n";
endforeach;
echo "\t);\n";
endif;
endif;

?>
//The Associations below have been created with all possible keys, those that are not needed can be removed
<?php

foreach (array('hasOne', 'belongsTo') as $assocType):
if (!empty($associations[$assocType])):
Expand Down Expand Up @@ -122,4 +127,5 @@ if (!empty($associations['hasAndBelongsToMany'])):
echo "\n\t);\n\n";
endif;
?>
}
<?php echo '?>'; ?>
1 change: 1 addition & 0 deletions cake/tests/cases/console/libs/tasks/model.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ function testBakeValidation() {
$pattern = '/' . preg_quote("'notempty' => array('rule' => array('notempty')),", '/') . '/';
$this->assertPattern($pattern, $result);
}

/**
* test baking relations
*
Expand Down

0 comments on commit a85bf16

Please sign in to comment.