Cml\Cml::showSystemTemplate PHP Method

showSystemTemplate() public static method

渲染显示系统模板
public static showSystemTemplate ( string $tpl )
$tpl string 要渲染的模板文件
    public static function showSystemTemplate($tpl)
    {
        $configSubFix = Config::get('html_template_suffix');
        Config::set('html_template_suffix', '');
        echo View::getEngine('html')->setHtmlEngineOptions('templateDir', dirname($tpl) . DIRECTORY_SEPARATOR)->fetch(basename($tpl), false, true, true);
        Config::set('html_template_suffix', $configSubFix);
    }

Usage Example

Esempio n. 1
0
 /**
  * 自定义异常处理
  *
  * @param mixed $e 异常对象
  */
 public function appException(&$e)
 {
     if (Cml::$debug) {
         $run = new Run();
         $run->pushHandler(Request::isCli() ? new PlainTextHandler() : new PrettyPageHandler());
         $run->handleException($e);
     } else {
         $error = [];
         $error['message'] = $e->getMessage();
         $trace = $e->getTrace();
         $error['files'][0] = $trace[0];
         if (substr($e->getFile(), -20) !== '\\Tools\\functions.php' || $e->getLine() !== 90) {
             array_unshift($error['files'], ['file' => $e->getFile(), 'line' => $e->getLine(), 'type' => 'throw']);
         }
         //正式环境 只显示‘系统错误’并将错误信息记录到日志
         Log::emergency($error['message'], [$error['files'][0]]);
         $error = [];
         $error['message'] = Lang::get('_CML_ERROR_');
         if (Request::isCli()) {
             \Cml\pd($error);
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             View::getEngine('html')->reset()->assign('error', $error);
             Cml::showSystemTemplate(Config::get('html_exception'));
         }
     }
     exit;
 }
All Usage Examples Of Cml\Cml::showSystemTemplate