From 507994ac859b81541ca7135ceade44f2b9f43b29 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 29 Mar 2018 23:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0template.auto=5Frule=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=A8=A1=E6=9D=BF=E6=B8=B2=E6=9F=93=E7=9A=84?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E5=A4=84=E7=90=86=E8=A7=84=E5=88=99=201=20?= =?UTF-8?q?=E4=B8=BA=E5=B0=8F=E5=86=99+=E4=B8=8B=E5=88=92=E7=BA=BF=20?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E4=B8=BA=20=E5=AE=8C=E5=85=A8=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 ++ helper.php | 3 --- library/think/Controller.php | 4 ---- library/think/view/driver/Php.php | 2 +- library/think/view/driver/Think.php | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/convention.php b/convention.php index 15e34963..31a0a0c1 100644 --- a/convention.php +++ b/convention.php @@ -116,6 +116,8 @@ return [ // +---------------------------------------------------------------------- 'template' => [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 + 'auto_rule' => 1, // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', // 视图基础目录,配置目录为所有模块的视图起始目录 diff --git a/helper.php b/helper.php index c2e7ffe9..12683cfd 100644 --- a/helper.php +++ b/helper.php @@ -443,9 +443,6 @@ if (!function_exists('view')) { */ function view($template = '', $vars = [], $replace = [], $code = 200) { - if ('' === $template) { - $template = Loader::parseName(request()->action(true)); - } return Response::create($template, 'view', $code)->replace($replace)->assign($vars); } } diff --git a/library/think/Controller.php b/library/think/Controller.php index 80b77d90..77225b73 100644 --- a/library/think/Controller.php +++ b/library/think/Controller.php @@ -117,10 +117,6 @@ class Controller */ protected function fetch($template = '', $vars = [], $replace = [], $config = []) { - if ('' === $template) { - $template = Loader::parseName($this->request->action(true)); - } - return $this->view->fetch($template, $vars, $replace, $config); } diff --git a/library/think/view/driver/Php.php b/library/think/view/driver/Php.php index fa505350..661932e0 100644 --- a/library/think/view/driver/Php.php +++ b/library/think/view/driver/Php.php @@ -132,7 +132,7 @@ class Php if ($controller) { if ('' == $template) { // 如果模板文件名为空 按照默认规则定位 - $template = str_replace('.', DS, $controller) . $depr . $request->action(); + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); } elseif (false === strpos($template, $depr)) { $template = str_replace('.', DS, $controller) . $depr . $template; } diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index 46829d51..b36eeff3 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -127,7 +127,7 @@ class Think if ($controller) { if ('' == $template) { // 如果模板文件名为空 按照默认规则定位 - $template = str_replace('.', DS, $controller) . $depr . $request->action(); + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); } elseif (false === strpos($template, $depr)) { $template = str_replace('.', DS, $controller) . $depr . $template; }