Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FilesystemLoader.php

function FilesystemLoader::findTemplate

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php \Drupal\Core\Template\Loader\FilesystemLoader::findTemplate()

Return value

string|null

8 calls to FilesystemLoader::findTemplate()
FilesystemLoader::exists in vendor/twig/twig/src/Loader/FilesystemLoader.php
FilesystemLoader::findTemplate in core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
FilesystemLoader::findTemplate in core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
FilesystemLoader::getCacheKey in vendor/twig/twig/src/Loader/FilesystemLoader.php
Gets the cache key to use for the cache for a given template name.
FilesystemLoader::getSourceContext in vendor/twig/twig/src/Loader/FilesystemLoader.php
Returns the source context for a given template logical name.

... See full list

3 methods override FilesystemLoader::findTemplate()
FilesystemLoader::findTemplate in core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
HelpTopicTwigLoader::findTemplate in core/modules/help/src/HelpTopicTwigLoader.php
ThemeRegistryLoader::findTemplate in core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php
Finds the path to the requested template.

File

vendor/twig/twig/src/Loader/FilesystemLoader.php, line 176

Class

FilesystemLoader
Loads template from the filesystem.

Namespace

Twig\Loader

Code

protected function findTemplate(string $name, bool $throw = true) {
    $name = $this->normalizeName($name);
    if (isset($this->cache[$name])) {
        return $this->cache[$name];
    }
    if (isset($this->errorCache[$name])) {
        if (!$throw) {
            return null;
        }
        throw new LoaderError($this->errorCache[$name]);
    }
    try {
        [
            $namespace,
            $shortname,
        ] = $this->parseName($name);
        $this->validateName($shortname);
    } catch (LoaderError $e) {
        if (!$throw) {
            return null;
        }
        throw $e;
    }
    if (!isset($this->paths[$namespace])) {
        $this->errorCache[$name] = \sprintf('There are no registered paths for namespace "%s".', $namespace);
        if (!$throw) {
            return null;
        }
        throw new LoaderError($this->errorCache[$name]);
    }
    foreach ($this->paths[$namespace] as $path) {
        if (!$this->isAbsolutePath($path)) {
            $path = $this->rootPath . $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 null;
    }
    throw new LoaderError($this->errorCache[$name]);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal