예제 #1
0
 /**
  * override function render of yii\base\ViewRenderer.
  *
  * @param yii\web\View $view
  * @param string       $file   absolute file path of view
  * @param array        $params params to view file
  *
  * @return string complied templete
  */
 public function render($view, $file, $params)
 {
     foreach ($this->viewPath as $path) {
         if (strncmp($path, '@', 1) === 0) {
             $path = Yii::getAlias($path);
             if (DIRECTORY_SEPARATOR === '\\') {
                 $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
             }
         }
         if (strpos($file, $path) === 0) {
             $file = ltrim(substr($file, strlen($path)), DIRECTORY_SEPARATOR);
             break;
         }
     }
     $path = pathinfo($file);
     if (!in_array($path['extension'], $this->finder->getExtensions())) {
         $this->finder->addExtension($path['extension']);
     }
     $file = $path['dirname'] . DIRECTORY_SEPARATOR . $path['filename'];
     $this->blade->share('app', \Yii::$app);
     $this->blade->share('view', $view);
     return $this->blade->make($file, $params)->render();
 }
예제 #2
0
파일: Factory.php 프로젝트: xiaoler/blade
 /**
  * Prepend a new namespace to the loader.
  *
  * @param  string  $namespace
  * @param  string|array  $hints
  * @return void
  */
 public function prependNamespace($namespace, $hints)
 {
     $this->finder->prependNamespace($namespace, $hints);
 }