1
|
<?php
|
2
|
|
3
|
/*
|
4
|
* This file is part of Twig.
|
5
|
*
|
6
|
* (c) 2009 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
|
|
12
|
/**
|
13
|
* Loads a template from a string.
|
14
|
*
|
15
|
* When using this loader with a cache mechanism, you should know that a new cache
|
16
|
* key is generated each time a template content "changes" (the cache key being the
|
17
|
* source code of the template). If you don't want to see your cache grows out of
|
18
|
* control, you need to take care of clearing the old cache file by yourself.
|
19
|
*
|
20
|
* @package twig
|
21
|
* @author Fabien Potencier <fabien@symfony.com>
|
22
|
*/
|
23
|
class Twig_Loader_String implements Twig_LoaderInterface
|
24
|
{
|
25
|
/**
|
26
|
* Gets the source code of a template, given its name.
|
27
|
*
|
28
|
* @param string $name The name of the template to load
|
29
|
*
|
30
|
* @return string The template source code
|
31
|
*/
|
32
|
public function getSource($name)
|
33
|
{
|
34
|
return $name;
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Gets the cache key to use for the cache for a given template name.
|
39
|
*
|
40
|
* @param string $name The name of the template to load
|
41
|
*
|
42
|
* @return string The cache key
|
43
|
*/
|
44
|
public function getCacheKey($name)
|
45
|
{
|
46
|
return $name;
|
47
|
}
|
48
|
|
49
|
/**
|
50
|
* Returns true if the template is still fresh.
|
51
|
*
|
52
|
* @param string $name The template name
|
53
|
* @param timestamp $time The last modification time of the cached template
|
54
|
*/
|
55
|
public function isFresh($name, $time)
|
56
|
{
|
57
|
return true;
|
58
|
}
|
59
|
}
|