public function Twig_Loader_Chain::exists

Check if we have the source code of a template, given its name.

Parameters

string $name The name of the template to check if we can load:

Return value

boolean If the template source code is handled by this loader or not

Overrides Twig_ExistsLoaderInterface::exists

File

drupal/core/vendor/twig/twig/lib/Twig/Loader/Chain.php, line 70

Class

Twig_Loader_Chain
Loads templates from other loaders.

Code

public function exists($name) {
  $name = (string) $name;
  if (isset($this->hasSourceCache[$name])) {
    return $this->hasSourceCache[$name];
  }
  foreach ($this->loaders as $loader) {
    if ($loader instanceof Twig_ExistsLoaderInterface && $loader
      ->exists($name)) {
      return $this->hasSourceCache[$name] = true;
    }
    try {
      $loader
        ->getSource($name);
      return $this->hasSourceCache[$name] = true;
    } catch (Twig_Error_Loader $e) {
    }
  }
  return $this->hasSourceCache[$name] = false;
}