结合phpdoc的要求和一部分自定义的规则,完成一下文档注释的例子。
<?php
/**
* backtraderActions 控制器文件
* @author zhuozi <lizhuo1985@gmail.com>
* @history 2008-01-06 09:09 create by zhuozi
* 2008-01-06 10:20 edit by zhuozi add a new function(List function)
* 2008-01-06 10:30 edit by zhuozi add comments of file
*/
require_once dirname(__FILE__).'/../lib/backtraderGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/backtraderGeneratorHelper.class.php';
/**
* backtraderActions 控制器类
*
* @author zhuozi<lizhuo1985@gmail.com>
*/
class backtraderActions extends autoBacktraderActions
{
/**
* List动作为了backtrader的过滤器对页面显示的影响,重置过滤器之后跳转index动作
*
* @author zhuozi <lizhuo1985@gmail.com>
* @history 2008-01-06 09:09 create by zhuozi
* 2008-01-06 09:09 edit by zhuozi add comment of function
* @param sfWebRequest $request
*
* @return void
*/
function executeList( sfWebRequest $request )
{
$this->getUser()->setAttribute('backtrader.filters', null, 'admin_module');
$this->getUser()->setAttribute('backtrader.sort', null, 'admin_module');
$this->getUser()->setAttribute('backtrader.page', 1, 'admin_module');
$this->redirect('backtrader/index');
}
}
<?php
/**
* backtraderform 定义表单内容,继承系统生成的BaseTraderForm用于表单验证
*
* @author zhuozi <lizhuo1985@gmail.com>
* @history 2008-01-06 09:09 create by zhuozi
* 2008-01-06 10:20 edit by zhuozi add a new function(configure function)
*/
/**
* BacktraderForm
*
* @author zhuozi<lizhuo1985@gmail.com>
*/
class BacktraderForm extends BaseTraderForm
{
/**
* Configures the current form
*
* @author zhuozi<lizhuo1985@gmail.com>
* @history 2008-01-05 17:30 create by zhuozi
*
* @return void
*/
public function configure()
{
$i18n = sfContext::getInstance()->getI18N();
//声明字段类型
$this->setWidget('name', new sfWidgetFormInput());
$this->setWidget('password', new sfWidgetFormInput());
$this->setWidget('email', new sfWidgetFormInput());
$this->setWidget('comment', new sfWidgetFormTextarea());
//验证条件
$this->setValidator('name', new sfValidatorString(array('max_length' => 60)));
$this->setValidator('password', new sfValidatorString(array('max_length' => 60)));
$this->setValidator('email', new sfValidatorEmail(array('required' => false), array('invalid' => $i18n->__('Invalid.'))));
}
}