Exemple #1
0
 /**
  * Checks if a root view exists
  *
  * @return boolean
  */
 protected function viewExists($view)
 {
     try {
         $this->factory->make('cache.' . $view, array())->render();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
Exemple #2
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();
 }
Exemple #3
0
 /**
  * Add a view instance to the view data.
  *
  * @param  string  $key
  * @param  string  $view
  * @param  array   $data
  * @return $this
  */
 public function nest($key, $view, array $data = [])
 {
     return $this->with($key, $this->factory->make($view, $data));
 }