这里奇怪的问题。使用 Yii 框架我有以下课程
class HtmlTableUi
{
public function __construct(CWebModule &$module,$data,$actions)
{
//...code goes here...
}
protected function renderTable()
{
//... code goes here ...
}
}
我可以从 SchedulerModule 类中的 HtmlTableUi 实例调用 HtmlTableUi::renderTable() ,该类是单独的应用程序模块中的主类。我的 SchedulerModule.php 文件:
<?php
Yii::import('scheduler.components.HtmlTableUi');
class SchedulerModule extends CWebModule
{
public function init()
{
parent::init();
}
public function beforeControllerAction($controller, $action)
{
return true;
}
public function printUI($data,$actions,$submitPath)
{
$ui = new HtmlTableUi($this,$data,$actions,$submitPath);
$ui->renderTable();
}
}
棘手的部分来了 - 当我以这种方式从视图(index.php)调用 SchudulerModule::printUI
<?php
$this->module->printUI($casino,$actions,null);
?>
代码流通过 SchudulerModule::printUI 直到到达调用renderTable的点($ui->renderTable();) 而是在该方法主体内的第一行执行,这与任何逻辑和规则相反,令人惊讶的是跳转到CHttpSession::close !!?
在调用renderTable之前注意调用堆栈
protected/modules/scheduler/SchedulerModule.php.SchedulerModule->printUI:153
protected/modules/scheduler/views/default/index.php.require:21
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CBaseController.php.CBaseController->renderInternal:127
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CBaseController.php.CBaseController->renderFile:96
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CController.php.CController->renderPartial:870
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CController.php.CController->render:783
protected/modules/scheduler/controllers/DefaultController.php.DefaultController->actionIndex:57
之后:
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CHttpSession.php.CHttpSession->close:134
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CHttpSession.php.SchedulerModule->printUI:0
protected/modules/scheduler/views/default/index.php.require:21
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CBaseController.php.CBaseController->renderInternal:127
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CBaseController.php.CBaseController->renderFile:96
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CController.php.CController->renderPartial:870
/home/default/workspace/src/vlt/web/yii-1.1.12.b600af/framework/web/CController.php.CController->render:783
protected/modules/scheduler/controllers/DefaultController.php.DefaultController->actionIndex:57
有没有人有类似的问题?谁能解释这种行为?