Explorar el Código

给 TemplateRender 传递完整的channel 信息

visuddhinanda hace 2 años
padre
commit
ea218a2914
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      app/Http/Api/MdRender.php

+ 3 - 1
app/Http/Api/MdRender.php

@@ -5,6 +5,7 @@ use Illuminate\Support\Str;
 use mustache\mustache;
 use mustache\mustache;
 use App\Models\DhammaTerm;
 use App\Models\DhammaTerm;
 use App\Models\PaliText;
 use App\Models\PaliText;
+use App\Models\Channel;
 use App\Http\Controllers\CorpusController;
 use App\Http\Controllers\CorpusController;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Log;
@@ -103,6 +104,7 @@ class MdRender{
             return "<span>xml解析错误{$e}</span>";
             return "<span>xml解析错误{$e}</span>";
         }
         }
 
 
+        $channelInfo = Channel::find($channelId);
 
 
         $tpl_list = $dom->xpath('//MdTpl');
         $tpl_list = $dom->xpath('//MdTpl');
         foreach ($tpl_list as $key => $tpl) {
         foreach ($tpl_list as $key => $tpl) {
@@ -132,7 +134,7 @@ class MdRender{
             /**
             /**
              * 生成模版参数
              * 生成模版参数
              */
              */
-            $tplRender = new TemplateRender($props,$channelId,$mode);
+            $tplRender = new TemplateRender($props,$channelInfo,$mode);
             $tplProps = $tplRender->render($tpl_name);
             $tplProps = $tplRender->render($tpl_name);
             if($tplProps){
             if($tplProps){
                 $tpl->addAttribute("props",$tplProps['props']);
                 $tpl->addAttribute("props",$tplProps['props']);