You are here

protected function Twig_Loader_Filesystem::findTemplate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Loader/Filesystem.php \Twig_Loader_Filesystem::findTemplate()
4 calls to Twig_Loader_Filesystem::findTemplate()
Twig_Loader_Filesystem::exists in vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Check if we have the source code of a template, given its name.
Twig_Loader_Filesystem::getCacheKey in vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Gets the cache key to use for the cache for a given template name.
Twig_Loader_Filesystem::getSource in vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Gets the source code of a template, given its name.
Twig_Loader_Filesystem::isFresh in vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Returns true if the template is still fresh.

File

vendor/twig/twig/lib/Twig/Loader/Filesystem.php, line 168

Class

Twig_Loader_Filesystem
Loads template from the filesystem.

Code

protected function findTemplate($name) {
  $throw = func_num_args() > 1 ? func_get_arg(1) : true;
  $name = $this
    ->normalizeName($name);
  if (isset($this->cache[$name])) {
    return $this->cache[$name];
  }
  if (isset($this->errorCache[$name])) {
    if (!$throw) {
      return false;
    }
    throw new Twig_Error_Loader($this->errorCache[$name]);
  }
  $this
    ->validateName($name);
  list($namespace, $shortname) = $this
    ->parseName($name);
  if (!isset($this->paths[$namespace])) {
    $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
    if (!$throw) {
      return false;
    }
    throw new Twig_Error_Loader($this->errorCache[$name]);
  }
  foreach ($this->paths[$namespace] as $path) {
    if (is_file($path . '/' . $shortname)) {
      if (false !== ($realpath = realpath($path . '/' . $shortname))) {
        return $this->cache[$name] = $realpath;
      }
      return $this->cache[$name] = $path . '/' . $shortname;
    }
  }
  $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
  if (!$throw) {
    return false;
  }
  throw new Twig_Error_Loader($this->errorCache[$name]);
}