【发布时间】:2013-05-15 18:53:24
【问题描述】:
我正在使用 Yii php 为一个项目创建一个审计跟踪模块,而且我是一个新手。众所周知,审计跟踪与历史、事务日志的创建有关......我已经为审计跟踪创建了一个模型 并为其生成了一个控制器以及一个单独的模型。 (当然使用 gii)
我的问题在于如何实际创建条目或线索(日志、历史记录,我不知道抱歉这个词 =3)
我的 AuditTrailController 有一个动作:
class AuditTrailController extends Controller{
public function actionCreate()
{
//do create the trail
}
}
我的计划是从整个项目中所有模块的所有其他控制器调用 actionCreate(),例如:
class StudyController extends Controller {
public function addRecord(){
//add some record
//---> i want to call the acionCreate() from the AuditTrailController from here
//to create an entry telling that the some user "user" at time "time"
//performed an "add" operation..
}
public function updateRecord(){
//update some record
//---> i want to call the acionCreate() from the AuditTrailController from here
//create an audit entry telling the user "updated"
}
}
-Yii:app() 不能解决问题..(或者我用错了)..
我已经搜索了很多答案,但他们说从一个控制器调用另一个控制器是“邪恶的”......我看到了使用组件之类的术语......其他说它应该在模型中完成......但我不知道.. 我是 OOP 和 Yii 的新手,所以我在这里很挣扎.. 帮帮我,谢谢.. 但如果以上是可能的,那么示例代码将非常有帮助,谢谢!
【问题讨论】:
标签: php function yii controller audit