Example #1
0
 /**
  * Clarify twig syntax exception.
  *
  * @param \Twig_Error_Syntax $error
  * @param LoaderInterface    $loader
  * @return self
  */
 public static function fromTwig(\Twig_Error_Syntax $error, LoaderInterface $loader)
 {
     $exception = new static($error->getMessage(), $error->getCode(), $error);
     $exception->file = $loader->localFilename($error->getTemplateFile());
     $exception->line = $error->getTemplateLine();
     return $exception;
 }
Example #2
0
 /**
  * Process compiled source using Stempler post-processors.
  *
  * @param string $source
  * @param string $path
  * @param string $compiledFilename
  * @return string
  */
 protected function processSource($source, $path, $compiledFilename = null)
 {
     foreach ($this->getProcessors() as $processor) {
         $benchmark = $this->benchmark('process', get_class($processor) . '-{' . $path);
         try {
             $source = $processor->process($source, $this->loader->viewNamespace($path), $this->loader->viewName($path), $compiledFilename);
         } finally {
             $this->benchmark($benchmark);
         }
     }
     return $source;
 }
Example #3
0
 /**
  * Get view loader.
  *
  * @param string $engine Forced extension value.
  * @return LoaderInterface
  */
 public function loader($engine = null)
 {
     $extension = null;
     if (!empty($engine)) {
         if (!$this->config->hasEngine($engine)) {
             throw new ViewsException("Undefined view engine '{$engine}'.");
         }
         $extension = $this->config->engineExtension($engine);
     }
     if (empty($extension)) {
         return $this->loader;
     }
     //todo: think about it
     return $this->loader->withExtension($extension);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function get($path)
 {
     return new NativeView($this->loader->localFilename($path), $this->loader->viewNamespace($path), $this->loader->viewName($path), $this->container);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function localFilename($path)
 {
     return $this->loader->localFilename($path);
 }