public findTemplate ( string $name ) : string | ||
$name | string | Template file name or path. |
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];
}
/** * 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; }