增加response的事件机制;为login增加事件;发布新版本

This commit is contained in:
2023-09-23 14:50:24 +08:00
parent e176ed19e5
commit 08c340a2bf
6 changed files with 90 additions and 16 deletions

View File

@@ -48,4 +48,36 @@ class View extends ThinkView
return $this;
}
/**
* 解析和获取模板内容 用于输出.
* @param string $template 模板文件名或者内容
* @param array $vars 模板变量
* @return string
* @throws \Exception
*/
public function fetch(string $template = '', array $vars = []): string
{
return $this->config([
'view_suffix' => 'html',
])->getContent(function () use ($vars, $template) {
$this->engine()->fetch($template, array_merge($this->data, $vars));
});
}
/**
* 解析和获取模板内容 用于输出.
* @param string $template 模板文件名或者内容
* @param array $vars 模板变量
* @return string
* @throws \Exception
*/
public function fetchJS(string $template = '', array $vars = []): string
{
return $this->config([
'view_suffix' => 'js',
])->getContent(function () use ($vars, $template) {
$this->engine()->fetch($template, array_merge($this->data, $vars));
});
}
}