TwigBridge\Twig\Loader::findTemplate PHP 메소드

findTemplate() 공개 메소드

Return path to template without the need for the extension.
public findTemplate ( string $name ) : string
$name string Template file name or path.
리턴 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];
    }

Usage Example

예제 #1
0
파일: Twig.php 프로젝트: rcrowe/twigbridge
 /**
  * Handle a TwigError exception.
  *
  * @param \Twig_Error $ex
  *
  * @throws \Twig_Error|\ErrorException
  */
 protected function handleTwigError(Twig_Error $ex)
 {
     $templateFile = $ex->getTemplateFile();
     $templateLine = $ex->getTemplateLine();
     if ($templateFile && file_exists($templateFile)) {
         $file = $templateFile;
     } elseif ($templateFile) {
         // Attempt to locate full path to file
         try {
             $file = $this->loader->findTemplate($templateFile);
         } catch (Twig_Error_Loader $exception) {
             // Unable to load template
         }
     }
     if (isset($file)) {
         $ex = new ErrorException($ex->getMessage(), 0, 1, $file, $templateLine, $ex);
     }
     throw $ex;
 }