mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Generating PHPDoc to baked files.
This commit is contained in:
parent
40bdcbb44a
commit
6002f10b3b
5 changed files with 130 additions and 0 deletions
|
@ -18,11 +18,22 @@
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <?php echo $admin ?>index method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function <?php echo $admin ?>index() {
|
public function <?php echo $admin ?>index() {
|
||||||
$this-><?php echo $currentModelName ?>->recursive = 0;
|
$this-><?php echo $currentModelName ?>->recursive = 0;
|
||||||
$this->set('<?php echo $pluralName ?>', $this->paginate());
|
$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) {
|
public function <?php echo $admin ?>view($id = null) {
|
||||||
$this-><?php echo $currentModelName; ?>->id = $id;
|
$this-><?php echo $currentModelName; ?>->id = $id;
|
||||||
if (!$this-><?php echo $currentModelName; ?>->exists()) {
|
if (!$this-><?php echo $currentModelName; ?>->exists()) {
|
||||||
|
@ -32,6 +43,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php $compact = array(); ?>
|
<?php $compact = array(); ?>
|
||||||
|
/**
|
||||||
|
* <?php echo $admin ?>add method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function <?php echo $admin ?>add() {
|
public function <?php echo $admin ?>add() {
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
$this-><?php echo $currentModelName; ?>->create();
|
$this-><?php echo $currentModelName; ?>->create();
|
||||||
|
@ -66,6 +82,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php $compact = array(); ?>
|
<?php $compact = array(); ?>
|
||||||
|
/**
|
||||||
|
* <?php echo $admin ?>edit method
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function <?php echo $admin; ?>edit($id = null) {
|
public function <?php echo $admin; ?>edit($id = null) {
|
||||||
$this-><?php echo $currentModelName; ?>->id = $id;
|
$this-><?php echo $currentModelName; ?>->id = $id;
|
||||||
if (!$this-><?php echo $currentModelName; ?>->exists()) {
|
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) {
|
public function <?php echo $admin; ?>delete($id = null) {
|
||||||
if (!$this->request->is('post')) {
|
if (!$this->request->is('post')) {
|
||||||
throw new MethodNotAllowedException();
|
throw new MethodNotAllowedException();
|
||||||
|
|
|
@ -21,13 +21,23 @@
|
||||||
|
|
||||||
echo "<?php\n";
|
echo "<?php\n";
|
||||||
?>
|
?>
|
||||||
|
/**
|
||||||
|
* <?php echo $controllerName; ?> Controller
|
||||||
|
*
|
||||||
|
*/
|
||||||
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
|
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
|
||||||
|
|
||||||
<?php if ($isScaffold): ?>
|
<?php if ($isScaffold): ?>
|
||||||
|
/**
|
||||||
|
* Scaffold
|
||||||
|
*
|
||||||
|
* @var mixed
|
||||||
|
*/
|
||||||
public $scaffold;
|
public $scaffold;
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php
|
<?php
|
||||||
if (count($helpers)):
|
if (count($helpers)):
|
||||||
|
echo "/**\n * Helpers\n *\n * @var array\n */\n";
|
||||||
echo "\tvar \$helpers = array(";
|
echo "\tvar \$helpers = array(";
|
||||||
for ($i = 0, $len = count($helpers); $i < $len; $i++):
|
for ($i = 0, $len = count($helpers); $i < $len; $i++):
|
||||||
if ($i != $len - 1):
|
if ($i != $len - 1):
|
||||||
|
@ -40,6 +50,7 @@ if (count($helpers)):
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if (count($components)):
|
if (count($components)):
|
||||||
|
echo "/**\n * Components\n *\n * @var array\n */\n";
|
||||||
echo "\tpublic \$components = array(";
|
echo "\tpublic \$components = array(";
|
||||||
for ($i = 0, $len = count($components); $i < $len; $i++):
|
for ($i = 0, $len = count($components); $i < $len; $i++):
|
||||||
if ($i != $len - 1):
|
if ($i != $len - 1):
|
||||||
|
|
|
@ -21,19 +21,44 @@
|
||||||
?>
|
?>
|
||||||
<?php echo '<?php' . "\n"; ?>
|
<?php echo '<?php' . "\n"; ?>
|
||||||
/* <?php echo $model; ?> Fixture generated on: <?php echo date('Y-m-d H:i:s') . " : ". time(); ?> */
|
/* <?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 {
|
class <?php echo $model; ?>Fixture extends CakeTestFixture {
|
||||||
<?php if ($table): ?>
|
<?php if ($table): ?>
|
||||||
|
/**
|
||||||
|
* Table name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $table = '<?php echo $table; ?>';
|
public $table = '<?php echo $table; ?>';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($import): ?>
|
<?php if ($import): ?>
|
||||||
|
/**
|
||||||
|
* Import
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $import = <?php echo $import; ?>;
|
public $import = <?php echo $import; ?>;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($schema): ?>
|
<?php if ($schema): ?>
|
||||||
|
/**
|
||||||
|
* Fields
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $fields = <?php echo $schema; ?>;
|
public $fields = <?php echo $schema; ?>;
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|
||||||
<?php if ($records): ?>
|
<?php if ($records): ?>
|
||||||
|
/**
|
||||||
|
* Records
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $records = <?php echo $records; ?>;
|
public $records = <?php echo $records; ?>;
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,22 +20,43 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo "<?php\n"; ?>
|
echo "<?php\n"; ?>
|
||||||
|
/**
|
||||||
|
* <?php echo $name ?> Model
|
||||||
|
*
|
||||||
|
*/
|
||||||
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
|
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
|
||||||
<?php if ($useDbConfig != 'default'): ?>
|
<?php if ($useDbConfig != 'default'): ?>
|
||||||
|
/**
|
||||||
|
* Use database config
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $useDbConfig = '<?php echo $useDbConfig; ?>';
|
public $useDbConfig = '<?php echo $useDbConfig; ?>';
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<?php if ($useTable && $useTable !== Inflector::tableize($name)):
|
<?php if ($useTable && $useTable !== Inflector::tableize($name)):
|
||||||
$table = "'$useTable'";
|
$table = "'$useTable'";
|
||||||
|
echo "/**\n * Use table\n *\n * @var mixed False or table name\n */\n";
|
||||||
echo "\tpublic \$useTable = $table;\n";
|
echo "\tpublic \$useTable = $table;\n";
|
||||||
endif;
|
endif;
|
||||||
if ($primaryKey !== 'id'): ?>
|
if ($primaryKey !== 'id'): ?>
|
||||||
|
/**
|
||||||
|
* Primary key field
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $primaryKey = '<?php echo $primaryKey; ?>';
|
public $primaryKey = '<?php echo $primaryKey; ?>';
|
||||||
<?php endif;
|
<?php endif;
|
||||||
if ($displayField): ?>
|
if ($displayField): ?>
|
||||||
|
/**
|
||||||
|
* Display field
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $displayField = '<?php echo $displayField; ?>';
|
public $displayField = '<?php echo $displayField; ?>';
|
||||||
<?php endif;
|
<?php endif;
|
||||||
|
|
||||||
if (!empty($validate)):
|
if (!empty($validate)):
|
||||||
|
echo "/**\n * Validation rules\n *\n * @var array\n */\n";
|
||||||
echo "\tpublic \$validate = array(\n";
|
echo "\tpublic \$validate = array(\n";
|
||||||
foreach ($validate as $field => $validations):
|
foreach ($validate as $field => $validations):
|
||||||
echo "\t\t'$field' => array(\n";
|
echo "\t\t'$field' => array(\n";
|
||||||
|
@ -57,6 +78,7 @@ endif;
|
||||||
foreach ($associations as $assoc):
|
foreach ($associations as $assoc):
|
||||||
if (!empty($assoc)):
|
if (!empty($assoc)):
|
||||||
?>
|
?>
|
||||||
|
|
||||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||||
<?php
|
<?php
|
||||||
break;
|
break;
|
||||||
|
@ -66,6 +88,7 @@ endforeach;
|
||||||
foreach (array('hasOne', 'belongsTo') as $assocType):
|
foreach (array('hasOne', 'belongsTo') as $assocType):
|
||||||
if (!empty($associations[$assocType])):
|
if (!empty($associations[$assocType])):
|
||||||
$typeCount = count($associations[$assocType]);
|
$typeCount = count($associations[$assocType]);
|
||||||
|
echo "\n/**\n * $assocType associations\n *\n * @var array\n */";
|
||||||
echo "\n\tpublic \$$assocType = array(";
|
echo "\n\tpublic \$$assocType = array(";
|
||||||
foreach ($associations[$assocType] as $i => $relation):
|
foreach ($associations[$assocType] as $i => $relation):
|
||||||
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
||||||
|
@ -86,6 +109,7 @@ endforeach;
|
||||||
|
|
||||||
if (!empty($associations['hasMany'])):
|
if (!empty($associations['hasMany'])):
|
||||||
$belongsToCount = count($associations['hasMany']);
|
$belongsToCount = count($associations['hasMany']);
|
||||||
|
echo "\n/**\n * hasMany associations\n *\n * @var array\n */";
|
||||||
echo "\n\tpublic \$hasMany = array(";
|
echo "\n\tpublic \$hasMany = array(";
|
||||||
foreach ($associations['hasMany'] as $i => $relation):
|
foreach ($associations['hasMany'] as $i => $relation):
|
||||||
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
||||||
|
@ -111,6 +135,7 @@ endif;
|
||||||
|
|
||||||
if (!empty($associations['hasAndBelongsToMany'])):
|
if (!empty($associations['hasAndBelongsToMany'])):
|
||||||
$habtmCount = count($associations['hasAndBelongsToMany']);
|
$habtmCount = count($associations['hasAndBelongsToMany']);
|
||||||
|
echo "\n/**\n * hasAndBelongsToMany associations\n *\n * @var array\n */";
|
||||||
echo "\n\tpublic \$hasAndBelongsToMany = array(";
|
echo "\n\tpublic \$hasAndBelongsToMany = array(";
|
||||||
foreach ($associations['hasAndBelongsToMany'] as $i => $relation):
|
foreach ($associations['hasAndBelongsToMany'] as $i => $relation):
|
||||||
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
$out = "\n\t\t'{$relation['alias']}' => array(\n";
|
||||||
|
|
|
@ -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;?>');
|
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
|
||||||
|
|
||||||
<?php if ($mock and strtolower($type) == 'controller'): ?>
|
<?php if ($mock and strtolower($type) == 'controller'): ?>
|
||||||
|
/**
|
||||||
|
* Test<?php echo $fullClassName; ?>
|
||||||
|
*
|
||||||
|
*/
|
||||||
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
|
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
|
||||||
|
/**
|
||||||
|
* Auto render
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
public $autoRender = false;
|
public $autoRender = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect action
|
||||||
|
*
|
||||||
|
* @param mixed $url
|
||||||
|
* @param mixed $status
|
||||||
|
* @param boolean $exit
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function redirect($url, $status = null, $exit = true) {
|
public function redirect($url, $status = null, $exit = true) {
|
||||||
$this->redirectUrl = $url;
|
$this->redirectUrl = $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
/**
|
||||||
|
* <?php echo $fullClassName; ?> Test Case
|
||||||
|
*
|
||||||
|
*/
|
||||||
class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
|
class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
|
||||||
<?php if (!empty($fixtures)): ?>
|
<?php if (!empty($fixtures)): ?>
|
||||||
|
/**
|
||||||
|
* Fixtures
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $fixtures = array('<?php echo join("', '", $fixtures); ?>');
|
public $fixtures = array('<?php echo join("', '", $fixtures); ?>');
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
/**
|
||||||
|
* startTest method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function startTest() {
|
public function startTest() {
|
||||||
$this-><?php echo $className . ' = ' . $construction; ?>
|
$this-><?php echo $className . ' = ' . $construction; ?>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* endTest method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function endTest() {
|
public function endTest() {
|
||||||
unset($this-><?php echo $className;?>);
|
unset($this-><?php echo $className;?>);
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php foreach ($methods as $method): ?>
|
<?php foreach ($methods as $method): ?>
|
||||||
|
/**
|
||||||
|
* test<?php echo Inflector::classify($method); ?> method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function test<?php echo Inflector::classify($method); ?>() {
|
public function test<?php echo Inflector::classify($method); ?>() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue