/**
  * Create a new database manager instance.
  *
  * @param  \Illuminate\Foundation\Application  $app
  * @return void
  */
 public function __construct(ViewFinderInterface $finder)
 {
     $this->finder = $finder;
     $this->finder->addExtension('array.php');
     $this->finder->addExtension('helper.php');
     $this->factory = new Factory($this->finder->getPaths(), $this->finder);
 }
Example #2
0
 /**
  * Return the evaluated template.
  *
  * @param string $path The file name with its file extension.
  * @param array  $data Template data (view data)
  *
  * @return string
  */
 public function get($path, array $data = [])
 {
     $file = array_search($path, $this->finder->getViews());
     // Allow the use of a '.' notation.
     $file = themosis_convert_path($file);
     $template = $this->environment->loadTemplate($file . $this->extension);
     return $template->render($data);
 }
 protected function doInclude($view, array $data = [])
 {
     // normalize $view
     // find file
     $path = $this->finder->find($view);
     $this->expandFile($path);
 }
Example #4
0
 /**
  * Return path to template without the need for the extension.
  *
  * @param string $name Template file name or path.
  *
  * @throws \Twig_Error_Loader
  * @return string Path to template
  */
 public function findTemplate($name)
 {
     if ($this->files->exists($name)) {
         return $name;
     }
     $name = $this->normalizeName($name);
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     try {
         $this->cache[$name] = $this->finder->find($name);
     } catch (InvalidArgumentException $ex) {
         throw new Twig_Error_Loader($ex->getMessage());
     }
     return $this->cache[$name];
 }
Example #5
0
 /**
  * Register a valid Markdown extension and its engine.
  *
  * @param  string   $extension
  * @param  string   $engine
  * @param  Closure  $resolver
  * @return void
  */
 public function addExtension($extension, $engine, $resolver = null)
 {
     $this->finder->addExtension($extension);
     if (isset($resolver)) {
         $this->engines->register($engine, $resolver);
     }
     $this->extensions[$extension] = $engine;
 }
Example #6
0
 /**
  * Register a valid view extension and its engine.
  *
  * @param  string    $extension
  * @param  string    $engine
  * @param  \Closure  $resolver
  * @return void
  */
 public function addExtension($extension, $engine, $resolver = null)
 {
     $this->finder->addExtension($extension);
     if (isset($resolver)) {
         $this->engines->register($engine, $resolver);
     }
     unset($this->extensions[$extension]);
     $this->extensions = array_merge([$extension => $engine], $this->extensions);
 }
 public function loadFile($name)
 {
     $path = $this->finder->find($name);
     return $this->files->get($path);
 }