题
是否有可能使用Yii框架另一控制器类中实例化一个控制器类
例如我有类学生的学生控制器和和方法actionShow我有以下
public function actionShow()
{
$student = $this->loadStudent();
$studentContact = new Student_ContactController;
//Checking if there was an ajax request
if(Yii::app()->request->isAjaxRequest){
$this->renderPartial('show',array(
'student'=>$student,
));
}else{
$this->render('show',array(
'student'=>$student,
));
}
}
是否有可能包含在所述方法中$ studentContact这个动作=新Student_ContactController;
获取错误,: - (
解决方案
我不知道Yii框架,但因为它是一个MVC框架,然后让数据应该是模型的一部分,因此$ studentContact应该不是一个控制器模型的实例。
如果你真的想实例化控制器的一个实例,然后调用与支架的构造器:
$studentContact = new Student_ContactController();
不隶属于 StackOverflow