Yii 框架从扩展 PHP 文件调用控制器方法


yii framework calling controller method from extension php file

我想在特定条件下从 yii 扩展调用控制器方法来触发部分渲染

<?php
require_once (Yii::app ()->basePath . '/controllers/SiteController.php';
$obj = new SiteController();
$obj->actionGetscore();
print_r($obj);
.....
.....
?>

Yii::app()->controller->actionGetscore();
Yii::app()->controller->renderPartial();
Yii::app()->controller->forward('site/getscore');
控制器不应该有业务逻辑,它们只需要请求>响应。
您需要使用模型或相同的类,在那里您可以使用:
Yii::app()->controller->renderPartial('/site/getscore', array('data'=>$data));