TestLoader.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
  2. 10 core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
  3. 11.x core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php

Namespace

Drupal\twig_loader_test\Loader

File

core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php

View source
<?php

namespace Drupal\twig_loader_test\Loader;

use Twig\Loader\LoaderInterface;
use Twig\Source;

/**
 * A test Twig loader.
 */
class TestLoader implements LoaderInterface {
    
    /**
     * {@inheritdoc}
     */
    public function getSourceContext($name) {
        $name = (string) $name;
        $value = $name === 'kittens' ? 'kittens' : 'cats';
        return new Source($value, $name);
    }
    
    /**
     * {@inheritdoc}
     */
    public function exists($name) {
        return TRUE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheKey($name) {
        return $name;
    }
    
    /**
     * {@inheritdoc}
     */
    public function isFresh($name, $time) {
        return TRUE;
    }

}

Classes

Title Deprecated Summary
TestLoader A test Twig loader.

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