コード例 #1
0
ファイル: ArrayLoader.php プロジェクト: ryosukemiyazawa/lasa
 public function getBuilder($name)
 {
     if (isset($this->container[$name])) {
         list($template, $func) = $this->container[$name];
         if ($func instanceof \Closure) {
             $compiler = new \lasa\view\builder\ClosureViewBuilder($func);
             $compiler->setTemplate($template);
         } else {
             if (is_array($func)) {
                 $compiler = new \lasa\view\builder\StandardViewBuilder($func, $template);
             }
         }
         return $compiler;
     }
     return null;
 }
コード例 #2
0
ファイル: FileLoader.php プロジェクト: ryosukemiyazawa/lasa
 public function getBuilder($name)
 {
     list($scriptPath, $templatePath) = $this->getPath($name);
     //存在しない場合
     if (!file_exists($scriptPath)) {
         return null;
     }
     //dummy view object
     $view = new BlankRender();
     //種類を調べるために一度読み込みを行う
     ob_start();
     $res = (include $scriptPath);
     ob_end_clean();
     if (is_array($res)) {
         $compiler = new \lasa\view\builder\StandardViewBuilder($res);
         if (file_exists($templatePath)) {
             $compiler->loadTemplate($templatePath);
         } else {
             $compiler->loadTemplate($scriptPath);
         }
         return $compiler;
     }
     if ($res instanceof \Closure) {
         $compiler = new \lasa\view\builder\ClosureViewBuilder($res);
         if (file_exists($templatePath)) {
             $compiler->setTemplate(file_get_contents($templatePath));
         } else {
             $compiler->loadTemplate();
         }
         return $compiler;
     }
     if ($res === 1) {
         $compiler = new \lasa\view\builder\PlainViewBuilder($scriptPath);
         return $compiler;
     }
     return null;
 }