1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12use Twig\Loader\ExistsLoaderInterface;
13use Twig\Loader\LoaderInterface;
14use Twig\Loader\SourceContextLoaderInterface;
15use Twig\Source;
16
17@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use "Twig\Loader\ArrayLoader" instead or "Twig\Environment::createTemplate()".', E_USER_DEPRECATED);
18
19/**
20 * Loads a template from a string.
21 *
22 * This loader should NEVER be used. It only exists for Twig internal purposes.
23 *
24 * When using this loader with a cache mechanism, you should know that a new cache
25 * key is generated each time a template content "changes" (the cache key being the
26 * source code of the template). If you don't want to see your cache grows out of
27 * control, you need to take care of clearing the old cache file by yourself.
28 *
29 * @deprecated since 1.18.1 (to be removed in 2.0)
30 *
31 * @internal
32 *
33 * @author Fabien Potencier <fabien@symfony.com>
34 */
35class Twig_Loader_String implements LoaderInterface, ExistsLoaderInterface, SourceContextLoaderInterface
36{
37    public function getSource($name)
38    {
39        @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', \get_class($this)), E_USER_DEPRECATED);
40
41        return $name;
42    }
43
44    public function getSourceContext($name)
45    {
46        return new Source($name, $name);
47    }
48
49    public function exists($name)
50    {
51        return true;
52    }
53
54    public function getCacheKey($name)
55    {
56        return $name;
57    }
58
59    public function isFresh($name, $time)
60    {
61        return true;
62    }
63}
64