Generating PHPDoc to baked files.

This commit is contained in:
Juan Basso 2011-01-19 22:22:50 -02:00
parent 40bdcbb44a
commit 6002f10b3b
5 changed files with 130 additions and 0 deletions

View file

@ -18,11 +18,22 @@
*/
?>
/**
* <?php echo $admin ?>index method
*
* @return void
*/
public function <?php echo $admin ?>index() {
$this-><?php echo $currentModelName ?>->recursive = 0;
$this->set('<?php echo $pluralName ?>', $this->paginate());
}
/**
* <?php echo $admin ?>view method
*
* @param string $id
* @return void
*/
public function <?php echo $admin ?>view($id = null) {
$this-><?php echo $currentModelName; ?>->id = $id;
if (!$this-><?php echo $currentModelName; ?>->exists()) {
@ -32,6 +43,11 @@
}
<?php $compact = array(); ?>
/**
* <?php echo $admin ?>add method
*
* @return void
*/
public function <?php echo $admin ?>add() {
if ($this->request->is('post')) {
$this-><?php echo $currentModelName; ?>->create();
@ -66,6 +82,12 @@
}
<?php $compact = array(); ?>
/**
* <?php echo $admin ?>edit method
*
* @param string $id
* @return void
*/
public function <?php echo $admin; ?>edit($id = null) {
$this-><?php echo $currentModelName; ?>->id = $id;
if (!$this-><?php echo $currentModelName; ?>->exists()) {
@ -104,6 +126,12 @@
?>
}
/**
* <?php echo $admin ?>delete method
*
* @param string $id
* @return void
*/
public function <?php echo $admin; ?>delete($id = null) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();

View file

@ -21,13 +21,23 @@
echo "<?php\n";
?>
/**
* <?php echo $controllerName; ?> Controller
*
*/
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
<?php if ($isScaffold): ?>
/**
* Scaffold
*
* @var mixed
*/
public $scaffold;
<?php else: ?>
<?php
if (count($helpers)):
echo "/**\n * Helpers\n *\n * @var array\n */\n";
echo "\tvar \$helpers = array(";
for ($i = 0, $len = count($helpers); $i < $len; $i++):
if ($i != $len - 1):
@ -40,6 +50,7 @@ if (count($helpers)):
endif;
if (count($components)):
echo "/**\n * Components\n *\n * @var array\n */\n";
echo "\tpublic \$components = array(";
for ($i = 0, $len = count($components); $i < $len; $i++):
if ($i != $len - 1):

View file

@ -21,19 +21,44 @@
?>
<?php echo '<?php' . "\n"; ?>
/* <?php echo $model; ?> Fixture generated on: <?php echo date('Y-m-d H:i:s') . " : ". time(); ?> */
/**
* <?php echo $model; ?>Fixture
*
*/
class <?php echo $model; ?>Fixture extends CakeTestFixture {
<?php if ($table): ?>
/**
* Table name
*
* @var string
*/
public $table = '<?php echo $table; ?>';
<?php endif; ?>
<?php if ($import): ?>
/**
* Import
*
* @var array
*/
public $import = <?php echo $import; ?>;
<?php endif; ?>
<?php if ($schema): ?>
/**
* Fields
*
* @var array
*/
public $fields = <?php echo $schema; ?>;
<?php endif;?>
<?php if ($records): ?>
/**
* Records
*
* @var array
*/
public $records = <?php echo $records; ?>;
<?php endif;?>
}

View file

@ -20,22 +20,43 @@
*/
echo "<?php\n"; ?>
/**
* <?php echo $name ?> Model
*
*/
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
<?php if ($useDbConfig != 'default'): ?>
/**
* Use database config
*
* @var string
*/
public $useDbConfig = '<?php echo $useDbConfig; ?>';
<?php endif;?>
<?php if ($useTable && $useTable !== Inflector::tableize($name)):
$table = "'$useTable'";
echo "/**\n * Use table\n *\n * @var mixed False or table name\n */\n";
echo "\tpublic \$useTable = $table;\n";
endif;
if ($primaryKey !== 'id'): ?>
/**
* Primary key field
*
* @var string
*/
public $primaryKey = '<?php echo $primaryKey; ?>';
<?php endif;
if ($displayField): ?>
/**
* Display field
*
* @var string
*/
public $displayField = '<?php echo $displayField; ?>';
<?php endif;
if (!empty($validate)):
echo "/**\n * Validation rules\n *\n * @var array\n */\n";
echo "\tpublic \$validate = array(\n";
foreach ($validate as $field => $validations):
echo "\t\t'$field' => array(\n";
@ -57,6 +78,7 @@ endif;
foreach ($associations as $assoc):
if (!empty($assoc)):
?>
//The Associations below have been created with all possible keys, those that are not needed can be removed
<?php
break;
@ -66,6 +88,7 @@ endforeach;
foreach (array('hasOne', 'belongsTo') as $assocType):
if (!empty($associations[$assocType])):
$typeCount = count($associations[$assocType]);
echo "\n/**\n * $assocType associations\n *\n * @var array\n */";
echo "\n\tpublic \$$assocType = array(";
foreach ($associations[$assocType] as $i => $relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";
@ -86,6 +109,7 @@ endforeach;
if (!empty($associations['hasMany'])):
$belongsToCount = count($associations['hasMany']);
echo "\n/**\n * hasMany associations\n *\n * @var array\n */";
echo "\n\tpublic \$hasMany = array(";
foreach ($associations['hasMany'] as $i => $relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";
@ -111,6 +135,7 @@ endif;
if (!empty($associations['hasAndBelongsToMany'])):
$habtmCount = count($associations['hasAndBelongsToMany']);
echo "\n/**\n * hasAndBelongsToMany associations\n *\n * @var array\n */";
echo "\n\tpublic \$hasAndBelongsToMany = array(";
foreach ($associations['hasAndBelongsToMany'] as $i => $relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";

View file

@ -23,30 +23,71 @@ echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " :
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
<?php if ($mock and strtolower($type) == 'controller'): ?>
/**
* Test<?php echo $fullClassName; ?>
*
*/
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
/**
* Auto render
*
* @var boolean
*/
public $autoRender = false;
/**
* Redirect action
*
* @param mixed $url
* @param mixed $status
* @param boolean $exit
* @return void
*/
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
<?php endif; ?>
/**
* <?php echo $fullClassName; ?> Test Case
*
*/
class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
<?php if (!empty($fixtures)): ?>
/**
* Fixtures
*
* @var array
*/
public $fixtures = array('<?php echo join("', '", $fixtures); ?>');
<?php endif; ?>
/**
* startTest method
*
* @return void
*/
public function startTest() {
$this-><?php echo $className . ' = ' . $construction; ?>
}
/**
* endTest method
*
* @return void
*/
public function endTest() {
unset($this-><?php echo $className;?>);
ClassRegistry::flush();
}
<?php foreach ($methods as $method): ?>
/**
* test<?php echo Inflector::classify($method); ?> method
*
* @return void
*/
public function test<?php echo Inflector::classify($method); ?>() {
}