class TestLoader

Same name in other branches
  1. 9 core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php \Drupal\twig_loader_test\Loader\TestLoader
  2. 10 core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php \Drupal\twig_loader_test\Loader\TestLoader
  3. 11.x core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php \Drupal\twig_loader_test\Loader\TestLoader

A test Twig loader.

Hierarchy

  • class \Drupal\twig_loader_test\Loader\TestLoader implements \Drupal\twig_loader_test\Loader\Twig_LoaderInterface, \Drupal\twig_loader_test\Loader\Twig_ExistsLoaderInterface, \Drupal\twig_loader_test\Loader\Twig_SourceContextLoaderInterface

Expanded class hierarchy of TestLoader

1 string reference to 'TestLoader'
twig_loader_test.services.yml in core/modules/system/tests/modules/twig_loader_test/twig_loader_test.services.yml
core/modules/system/tests/modules/twig_loader_test/twig_loader_test.services.yml
1 service uses TestLoader
twig_loader_test.twig.test_loader in core/modules/system/tests/modules/twig_loader_test/twig_loader_test.services.yml
Drupal\twig_loader_test\Loader\TestLoader

File

core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php, line 10

Namespace

Drupal\twig_loader_test\Loader
View source
class TestLoader implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface, \Twig_SourceContextLoaderInterface {
    
    /**
     * {@inheritdoc}
     */
    public function getSourceContext($name) {
        $name = (string) $name;
        $value = $name === 'kittens' ? 'kittens' : 'cats';
        return new Source($value, $name);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getSource($name) {
        return $this->getSourceContext($name)
            ->getCode();
    }
    
    /**
     * {@inheritdoc}
     */
    public function exists($name) {
        return TRUE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheKey($name) {
        return $name;
    }
    
    /**
     * {@inheritdoc}
     */
    public function isFresh($name, $time) {
        return TRUE;
    }

}

Members

Title Sort descending Modifiers Object type Summary
TestLoader::exists public function
TestLoader::getCacheKey public function
TestLoader::getSource public function
TestLoader::getSourceContext public function
TestLoader::isFresh public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.