From 1dd547d04ff33e964b3c23297a6b0fe94048bf62 Mon Sep 17 00:00:00 2001 From: topnuomi <1130395124@qq.com> Date: Thu, 25 Jul 2019 23:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=BB=98=E8=AE=A4=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=BC=95=E6=93=8E=E9=A9=B1=E5=8A=A8=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/library/template/driver/Top.php | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/framework/library/template/driver/Top.php b/framework/library/template/driver/Top.php index c93151f..f60627e 100644 --- a/framework/library/template/driver/Top.php +++ b/framework/library/template/driver/Top.php @@ -9,18 +9,38 @@ use top\library\template\ifs\TemplateIfs; class Top implements TemplateIfs { + /** + * @var null 当前实例 + */ private static $instance = null; + /** + * @var null 模板引擎实现 + */ private $engine = null; + /** + * @var null 模板配置 + */ private $config = null; + /** + * @var bool 缓存状态 + */ private $cache = false; + /** + * 构造方法 + * Top constructor. + */ private function __construct() { } + /** + * 外部获取当前类实例 + * @return null|Top + */ public static function instance() { if (!self::$instance) { @@ -36,6 +56,11 @@ class Top implements TemplateIfs return $this; } + /** + * 编译文件 + * @param $filename + * @return string + */ private function compile($filename) { $compileFileName = $this->config['compileDir'] . md5($filename) . '.php'; @@ -51,11 +76,21 @@ class Top implements TemplateIfs return $compileFileName; } + /** + * @param $status + */ public function cache($status) { $this->cache = $status; } + /** + * 缓存文件 + * @param $filename + * @param $params + * @return string + * @throws \Exception + */ private function cacheFile($filename, $params) { @@ -78,6 +113,14 @@ class Top implements TemplateIfs } } + /** + * 渲染文件并返回内容 + * @param $file + * @param $params + * @param $cache + * @return bool|false|mixed|string + * @throws \Exception + */ public function fetch($file, $params, $cache) { $filename = $this->config['dir'] . $file . '.' . $this->config['ext'];