From 7e304cacf0f908198f1454baaa836c499a4fd170 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Thu, 19 Dec 2019 07:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/base/CatchController.php | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/extend/catcher/base/CatchController.php b/extend/catcher/base/CatchController.php index 058d26b..367c70a 100644 --- a/extend/catcher/base/CatchController.php +++ b/extend/catcher/base/CatchController.php @@ -25,18 +25,39 @@ abstract class CatchController $stack = \debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $end = end($stack); - View::config([ - 'view_path' => CatchAdmin::getViews()[$this->getModule($end['class'])], - ]); - if (!empty($this->data)) { - $data = array_merge($this->data, $data); - } + View::config($this->getViewPath($end['class'])); - $data['layout'] = root_path('view') . 'layout.html'; + $this->setLayout(); - return View::fetch($template ? : $this->getTemp($end['class'], $end['function']), $data); + $template = $template ? : $this->getTemp($end['class'], $end['function']); + return View::fetch($template, array_merge($this->data, $data)); + + } + + /** + * + * + * @time 2019年12月17日 + * @param $module + * @return array + */ + protected function getViewPath($module): array + { + return [ + 'view_path' => CatchAdmin::getViews()[$this->getModule($module)], + ]; + } + + /** + * + * @time 2019年12月17日 + * @return void + */ + protected function setLayout(): void + { + $this->data['layout'] = root_path('view') . 'layout.html'; } /** @@ -46,7 +67,7 @@ abstract class CatchController * @param $func * @return string */ - protected function getTemp($class, $func) + protected function getTemp($class, $func): string { $viewPath = CatchAdmin::getModuleViewPath($this->getModule($class));