2021/11/25 17:10:47 [error] 74701#0: *1 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1
无法调用内部变量,当模板中调用displayWidget会出错
//类似视图类
class View extends \Yaf\View\Simple {
protected $_test;//扩展冲突
public function get_tpl_vars() {
return $this->tpl_vars;//变量为null
}
/**
@param $widget string 视图插件
@param $viewPath string 视图插件模板
@param $vars array 传递变量
@param $data array 返回值
*/
public function displayWidget($widget, $viewPath, $vars=array(), &$data = array()) {
if (!$viewPath) {
throw new \Exception('部件模板路径不能为空', 500);
}
//创建视图
$config = \Yaf\Registry::get('config');
$applicationPath = $config->get('application.directory');
$tpl_dir = $applicationPath . 'views';
$view = new \Ku\View($tpl_dir);
//实现逻辑,并赋值到$vars
//$widgetClass = '\Business\Widget\'.$widget;
//$widgetBs = new $widgetClass;
//赋值模板变量
foreach($vars as $key => $value) {
$view->assign($key, $value);
}
//渲染
$config = \Yaf\Registry::get('config');
$ext = $config->get('application.view.ext');
echo $this->getView()->render($viewPath.'.'.$ext);
if (func_num_args() > 4) {
$data = $view->get_tpl_vars();
}
}
}
public function displayWidget($viewPath, $widgetName, $vars = array(), $tplVars = array(), &$data = array()) {
自己创建的继承视图,在3.1.4正常,在3.3.3出现一下问题
无法调用内部变量,当模板中调用displayWidget会出错
public function displayWidget($viewPath, $widgetName, $vars = array(), $tplVars = array(), &$data = array()) {