Ejemplo n.º 1
0
 /**
  * Compile the view at the given path.
  *
  * @param  string  $path
  * @return void
  */
 public function compile($path)
 {
     // View finder.
     $finder = $this->view->getFinder();
     // Get the list of view paths from the app.
     $paths = $finder->getPaths();
     // Get hints.
     $hints = $finder->getHints();
     // Get current theme uses.
     $currentThemeUses = \Theme::getThemeNamespace();
     if (isset($hints[$currentThemeUses])) {
         $paths = array_merge($paths, $hints[$currentThemeUses]);
     }
     // Get the directory the requested view sits in.
     $viewdir = dirname($path);
     // Match it to a view path registered in config::view.paths
     foreach ($paths as $dir) {
         if (stristr($viewdir, $dir)) {
             $path = str_replace($dir . '/', '', $path);
             break;
         }
     }
     // Create a loader for this template.
     $loader = new Twig_Loader_Filesystem($paths);
     // Instance compiler.
     $twig = $this->getTwigCompiler($loader);
     return $twig->render($path, $this->data);
 }
Ejemplo n.º 2
0
 public function __construct(Request $request, Factory $factory)
 {
     $this->request = $request;
     $this->view_path = realpath(base_path('resources/views'));
     $this->factory = $factory;
     $this->finder = $factory->getFinder();
     $this->finder->addExtension('schema.php');
 }
Ejemplo n.º 3
0
 public function __construct(Request $request, Factory $factory, array $data, $sources = [], $meta = [])
 {
     $this->request = $request;
     $this->data = $data;
     $this->sources = $sources;
     $this->factory = $factory;
     $this->finder = $factory->getFinder();
     if ($meta) {
         $this->data['jsonapi'] = array_filter($meta);
     }
 }
Ejemplo n.º 4
0
 /**
  * Get the normalized name, for creator/composer events
  *
  * @param  \Illuminate\View\Factory $viewEnvironment
  * @return string
  */
 protected function getNormalizedName($viewEnvironment)
 {
     $paths = $viewEnvironment->getFinder()->getPaths();
     $name = $this->getTemplateName();
     // Replace absolute paths, trim slashes, remove extension
     $name = str_replace($paths, '', $name);
     $name = ltrim($name, '/');
     if (substr($name, -5, 5) === '.twig') {
         $name = substr($name, 0, -5);
     }
     return $name;
 }
Ejemplo n.º 5
0
 /**
  * Load a theme
  *
  * @param string $theme
  * @throws \Exception
  */
 private function loadTheme($theme)
 {
     if (!isset($theme)) {
         return;
     }
     $th = $this->findThemeByDirectory($theme);
     if (isset($th)) {
         $viewFinder = $this->view->getFinder();
         $viewFinder->prependPath($th->getPath());
         if (!is_null($th->getParent())) {
             $this->loadTheme($th->getParent());
         }
         $this->activeTheme = $theme;
     }
 }
 private function getSections($parent)
 {
     $sections = [];
     if (!$this->view->exists($parent)) {
         $this->warn("Could not find view: {$parent}");
         return $sections;
     }
     $path = $this->view->getFinder()->find($parent);
     $content = $this->file->get($path);
     if (preg_match_all('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', $content, $matches)) {
         for ($i = 0; $i < count($matches[1]); $i++) {
             if ($matches[1][$i] == 'yield') {
                 $sections[] = $matches[4][$i];
             }
         }
     }
     return $sections;
 }
Ejemplo n.º 7
0
 /**
  * Get the view finder instance.
  *
  * @return \Illuminate\View\ViewFinderInterface 
  * @static 
  */
 public static function getFinder()
 {
     return \Illuminate\View\Factory::getFinder();
 }
Ejemplo n.º 8
0
 /**
  * Find view location.
  *
  * @param  boolean $realpath
  * @return string
  */
 public function location($realpath = false)
 {
     if ($this->view->exists($this->content)) {
         return $realpath ? $this->view->getFinder()->find($this->content) : $this->content;
     }
 }
Ejemplo n.º 9
0
 /**
  * @return array
  */
 public function getViewHints()
 {
     return $this->view->getFinder()->getHints();
 }