我正在使用 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 的新手,所以我在这里很挣扎.. 帮帮我,谢谢.. 但如果上述情况可行,那么示例代码将非常有帮助,谢谢!